aboutsummaryrefslogtreecommitdiffstats
path: root/test/Transforms
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2013-06-29 21:17:04 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2013-06-29 21:17:04 +0000
commitedac9151fdc24dc2d1eb4692bbfdd71baca12949 (patch)
treeaea81786b16d439a1c1fbc3e97c5a48d64355f90 /test/Transforms
parent97daabf318ff4751aca49bc1c334d2553b125671 (diff)
downloadexternal_llvm-edac9151fdc24dc2d1eb4692bbfdd71baca12949.zip
external_llvm-edac9151fdc24dc2d1eb4692bbfdd71baca12949.tar.gz
external_llvm-edac9151fdc24dc2d1eb4692bbfdd71baca12949.tar.bz2
InstCombine: Also turn selects fed by an and into arithmetic when the types don't match.
Inserting a zext or trunc is sufficient. This pattern is somewhat common in LLVM's pointer mangling code. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185270 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms')
-rw-r--r--test/Transforms/InstCombine/select.ll36
1 files changed, 36 insertions, 0 deletions
diff --git a/test/Transforms/InstCombine/select.ll b/test/Transforms/InstCombine/select.ll
index c72a6f7..5bf9423 100644
--- a/test/Transforms/InstCombine/select.ll
+++ b/test/Transforms/InstCombine/select.ll
@@ -985,3 +985,39 @@ define i32 @select_icmp_ne_0_and_8_or_1073741824(i8 %x, i32 %y) {
%select = select i1 %cmp, i32 %y, i32 %or
ret i32 %select
}
+
+define i32 @test65(i64 %x) {
+ %1 = and i64 %x, 16
+ %2 = icmp ne i64 %1, 0
+ %3 = select i1 %2, i32 40, i32 42
+ ret i32 %3
+
+; CHECK: @test65
+; CHECK: and i64 %x, 16
+; CHECK: trunc i64 %1 to i32
+; CHECK: lshr exact i32 %2, 3
+; CHECK: xor i32 %3, 42
+}
+
+define i32 @test66(i64 %x) {
+ %1 = and i64 %x, 4294967296
+ %2 = icmp ne i64 %1, 0
+ %3 = select i1 %2, i32 40, i32 42
+ ret i32 %3
+
+; CHECK: @test66
+; CHECK: select
+}
+
+define i32 @test67(i16 %x) {
+ %1 = and i16 %x, 4
+ %2 = icmp ne i16 %1, 0
+ %3 = select i1 %2, i32 40, i32 42
+ ret i32 %3
+
+; CHECK: @test67
+; CHECK: and i16 %x, 4
+; CHECK: zext i16 %1 to i32
+; CHECK: lshr exact i32 %2, 1
+; CHECK: xor i32 %3, 42
+}