summaryrefslogtreecommitdiff
path: root/test/Transforms
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-02-18 19:28:47 +0000
committerChris Lattner <sabre@nondot.org>2003-02-18 19:28:47 +0000
commit5640f333313f63ac709e99e57ae455e49ccb8fc6 (patch)
tree00954d247bebd3724f0e5f1260dea1096597f8a0 /test/Transforms
parenta2881961b918c89445666aa564680eb65867610a (diff)
downloadllvm-5640f333313f63ac709e99e57ae455e49ccb8fc6.tar.gz
llvm-5640f333313f63ac709e99e57ae455e49ccb8fc6.tar.bz2
llvm-5640f333313f63ac709e99e57ae455e49ccb8fc6.tar.xz
test for a variety of new transformations:
* A & ~A == 0 * A / (2^c) == A >> c if unsigned * 0 / A == 0 * 1.0 * A == A * A * (2^c) == A << c * A ^ ~A == -1 * A | ~A == -1 * 0 % X = 0 * A % (2^c) == A & (c-1) if unsigned * A - (A & B) == A & ~B * -1 - A == ~A git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5588 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms')
-rw-r--r--test/Transforms/InstCombine/and.ll5
-rw-r--r--test/Transforms/InstCombine/div.ll10
-rw-r--r--test/Transforms/InstCombine/mul.ll9
-rw-r--r--test/Transforms/InstCombine/or.ll11
-rw-r--r--test/Transforms/InstCombine/rem.ll11
-rw-r--r--test/Transforms/InstCombine/sub.ll12
6 files changed, 57 insertions, 1 deletions
diff --git a/test/Transforms/InstCombine/and.ll b/test/Transforms/InstCombine/and.ll
index 4c151bdeea..7dd3d554b6 100644
--- a/test/Transforms/InstCombine/and.ll
+++ b/test/Transforms/InstCombine/and.ll
@@ -38,3 +38,8 @@ bool %test6(bool %A) {
ret bool %B
}
+int %test7(int %A) { ; A & ~A == 0
+ %NotA = xor int %A, -1
+ %B = and int %A, %NotA
+ ret int %B
+} \ No newline at end of file
diff --git a/test/Transforms/InstCombine/div.ll b/test/Transforms/InstCombine/div.ll
index 10daccf11c..2bcd452c23 100644
--- a/test/Transforms/InstCombine/div.ll
+++ b/test/Transforms/InstCombine/div.ll
@@ -12,3 +12,13 @@ int %test1(int %A) {
%B = div int %A, 1
ret int %B
}
+
+uint %test2(uint %A) {
+ %B = div uint %A, 8 ; => Shift
+ ret int %B
+}
+
+int %test3(int %A) {
+ %B = div int 0, %A ; => 0, don't need to keep traps
+ ret int %B
+}
diff --git a/test/Transforms/InstCombine/mul.ll b/test/Transforms/InstCombine/mul.ll
index 793040e877..3f171f4522 100644
--- a/test/Transforms/InstCombine/mul.ll
+++ b/test/Transforms/InstCombine/mul.ll
@@ -26,3 +26,12 @@ begin
ret int %B
end
+double %test4(double %A) {
+ %B = mul double 1.0, %A ; This is safe for FP
+ ret double %B
+}
+
+int %test5(int %A) {
+ %B = mul int %A, 8
+ ret int %B
+}
diff --git a/test/Transforms/InstCombine/or.ll b/test/Transforms/InstCombine/or.ll
index 453df5581c..3358715d1f 100644
--- a/test/Transforms/InstCombine/or.ll
+++ b/test/Transforms/InstCombine/or.ll
@@ -58,3 +58,14 @@ int %test10(int %A) {
ret int %B
}
+int %test11(int %A) { ; A ^ ~A == -1
+ %NotA = xor int -1, %A
+ %B = xor int %A, %NotA
+ ret int %B
+}
+
+int %test12(int %A) { ; A | ~A == -1
+ %NotA = xor int -1, %A
+ %B = or int %A, %NotA
+ ret int %B
+}
diff --git a/test/Transforms/InstCombine/rem.ll b/test/Transforms/InstCombine/rem.ll
index 554c059b1f..ddc1c4b0c6 100644
--- a/test/Transforms/InstCombine/rem.ll
+++ b/test/Transforms/InstCombine/rem.ll
@@ -8,8 +8,17 @@
implementation
-int "test1"(int %A) {
+int %test1(int %A) {
%B = rem int %A, 1 ; ISA constant 0
ret int %B
}
+int %test2(int %A) { ; 0 % X = 0, we don't need ot preserve traps
+ %B = rem int 0, %A
+ ret int %B
+}
+
+uint %test3(uint %A) {
+ %B = rem uint %A, 8 ; & 7
+ ret uint %B
+}
diff --git a/test/Transforms/InstCombine/sub.ll b/test/Transforms/InstCombine/sub.ll
index cf9011573d..f807d7e042 100644
--- a/test/Transforms/InstCombine/sub.ll
+++ b/test/Transforms/InstCombine/sub.ll
@@ -35,3 +35,15 @@ int "test5"(int %A, int %Bok, int %Cok) {
%E = sub int %A, %D
ret int %E
}
+
+int %test6(int %A, int %B) {
+ %C = and int %A, %B ; A - (A & B) => A & ~B
+ %D = sub int %A, %C
+ ret int %D
+}
+
+int %test7(int %A) {
+ %B = sub int -1, %A ; B = ~A
+ ret int %B
+}
+