summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2010-09-10 22:39:55 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2010-09-10 22:39:55 +0000
commit6844c8ea5a67e551be7106d6b7b9e1a64eecbe51 (patch)
treeb11daf32edb5ff3fbb9e4d75e0d12a14661da301 /test
parente2d50046fd29cb3eb2483e080cb7c39b460fbb19 (diff)
downloadllvm-6844c8ea5a67e551be7106d6b7b9e1a64eecbe51.tar.gz
llvm-6844c8ea5a67e551be7106d6b7b9e1a64eecbe51.tar.bz2
llvm-6844c8ea5a67e551be7106d6b7b9e1a64eecbe51.tar.xz
Teach InstructionSimplify to fold (A & B) & A -> A & B and (A | B) | A -> A | B.
Reassociate does this but it doesn't catch all cases (e.g. if the operands are i1). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@113651 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r--test/Transforms/InstCombine/and2.ll18
-rw-r--r--test/Transforms/InstCombine/or.ll17
2 files changed, 35 insertions, 0 deletions
diff --git a/test/Transforms/InstCombine/and2.ll b/test/Transforms/InstCombine/and2.ll
index a5a6574e9f..d898ea3b03 100644
--- a/test/Transforms/InstCombine/and2.ll
+++ b/test/Transforms/InstCombine/and2.ll
@@ -8,3 +8,21 @@ define i1 @test1(double %X, double %Y) {
ret i1 %bothcond
; CHECK: fcmp ord double %Y, %X
}
+
+define i1 @test2(i1 %X, i1 %Y) {
+ %a = and i1 %X, %Y
+ %b = and i1 %a, %X
+ ret i1 %b
+; CHECK: @test2
+; CHECK-NEXT: and i1 %X, %Y
+; CHECK-NEXT: ret
+}
+
+define i32 @test3(i32 %X, i32 %Y) {
+ %a = and i32 %X, %Y
+ %b = and i32 %Y, %a
+ ret i32 %b
+; CHECK: @test3
+; CHECK-NEXT: and i32 %X, %Y
+; CHECK-NEXT: ret
+}
diff --git a/test/Transforms/InstCombine/or.ll b/test/Transforms/InstCombine/or.ll
index c3526b77f6..eb887ecb7b 100644
--- a/test/Transforms/InstCombine/or.ll
+++ b/test/Transforms/InstCombine/or.ll
@@ -350,3 +350,20 @@ define <4 x i32> @test32(<4 x i1> %and.i1352, <4 x i32> %vecinit6.i176, <4 x i32
; CHECK: or <4 x i32> %and.i, %and.i129
}
+define i1 @test33(i1 %X, i1 %Y) {
+ %a = or i1 %X, %Y
+ %b = or i1 %a, %X
+ ret i1 %b
+; CHECK: @test33
+; CHECK-NEXT: or i1 %X, %Y
+; CHECK-NEXT: ret
+}
+
+define i32 @test34(i32 %X, i32 %Y) {
+ %a = or i32 %X, %Y
+ %b = or i32 %Y, %a
+ ret i32 %b
+; CHECK: @test34
+; CHECK-NEXT: or i32 %X, %Y
+; CHECK-NEXT: ret
+}