summaryrefslogtreecommitdiffstats
path: root/llvm/test
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2011-05-27 13:00:16 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2011-05-27 13:00:16 +0000
commit749ef5f420e3fca8fe582195462e629673a2b3fa (patch)
tree0b08cf4d379c89ce6128d55d65dd6685bf7549ed /llvm/test
parent34ef49dc74e68f9364c1e14195bd19f9232927fc (diff)
downloadbcm5719-llvm-749ef5f420e3fca8fe582195462e629673a2b3fa.tar.gz
bcm5719-llvm-749ef5f420e3fca8fe582195462e629673a2b3fa.zip
InstCombine: Make switch folding with equality compares more aggressive by trying instsimplify on the arm where we know the compared value.
Stuff like "x == y ? y : x&y" now folds into "x&y". llvm-svn: 132185
Diffstat (limited to 'llvm/test')
-rw-r--r--llvm/test/Transforms/InstCombine/select.ll40
1 files changed, 40 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstCombine/select.ll b/llvm/test/Transforms/InstCombine/select.ll
index 39259078b87..379228512cd 100644
--- a/llvm/test/Transforms/InstCombine/select.ll
+++ b/llvm/test/Transforms/InstCombine/select.ll
@@ -749,3 +749,43 @@ define i1 @test55(i1 %X, i32 %Y, i32 %Z) {
; CHECK: icmp eq
; CHECK: ret i1
}
+
+define i32 @test56(i16 %x) nounwind {
+ %tobool = icmp eq i16 %x, 0
+ %conv = zext i16 %x to i32
+ %cond = select i1 %tobool, i32 0, i32 %conv
+ ret i32 %cond
+; CHECK: @test56
+; CHECK-NEXT: zext
+; CHECK-NEXT: ret
+}
+
+define i32 @test57(i32 %x, i32 %y) nounwind {
+ %and = and i32 %x, %y
+ %tobool = icmp eq i32 %x, 0
+ %.and = select i1 %tobool, i32 0, i32 %and
+ ret i32 %.and
+; CHECK: @test57
+; CHECK-NEXT: and i32 %x, %y
+; CHECK-NEXT: ret
+}
+
+define i32 @test58(i16 %x) nounwind {
+ %tobool = icmp ne i16 %x, 1
+ %conv = zext i16 %x to i32
+ %cond = select i1 %tobool, i32 %conv, i32 1
+ ret i32 %cond
+; CHECK: @test58
+; CHECK-NEXT: zext
+; CHECK-NEXT: ret
+}
+
+define i32 @test59(i32 %x, i32 %y) nounwind {
+ %and = and i32 %x, %y
+ %tobool = icmp ne i32 %x, %y
+ %.and = select i1 %tobool, i32 %and, i32 %y
+ ret i32 %.and
+; CHECK: @test59
+; CHECK-NEXT: and i32 %x, %y
+; CHECK-NEXT: ret
+}
OpenPOWER on IntegriCloud