aboutsummaryrefslogtreecommitdiffstats
path: root/test/Transforms
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2009-06-17 23:17:05 +0000
committerDan Gohman <gohman@apple.com>2009-06-17 23:17:05 +0000
commitead83a5c70ca5298be7ea5073dac98b6f87407e0 (patch)
treea5fbc37b49faa79cc1ab407f256d303a7095dfd3 /test/Transforms
parentf7852896b5b48c913e11692a2204e387f97b48a2 (diff)
downloadexternal_llvm-ead83a5c70ca5298be7ea5073dac98b6f87407e0.zip
external_llvm-ead83a5c70ca5298be7ea5073dac98b6f87407e0.tar.gz
external_llvm-ead83a5c70ca5298be7ea5073dac98b6f87407e0.tar.bz2
Instcombine zext(trunc(x) & mask) to x&mask, even if the trunc has
multiple users. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73656 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms')
-rw-r--r--test/Transforms/InstCombine/trunc-mask-ext.ll23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/Transforms/InstCombine/trunc-mask-ext.ll b/test/Transforms/InstCombine/trunc-mask-ext.ll
new file mode 100644
index 0000000..1499947
--- /dev/null
+++ b/test/Transforms/InstCombine/trunc-mask-ext.ll
@@ -0,0 +1,23 @@
+; RUN: llvm-as < %s | opt -instcombine | llvm-dis > %t
+; RUN: not grep zext %t
+; RUN: not grep sext %t
+
+; Instcombine should be able to eliminate both ext casts.
+
+declare void @use(i32)
+
+define i64 @foo(i64 %a) {
+ %b = trunc i64 %a to i32
+ %c = and i32 %b, 15
+ %d = zext i32 %c to i64
+ call void @use(i32 %b)
+ ret i64 %d
+}
+define i64 @bar(i64 %a) {
+ %b = trunc i64 %a to i32
+ %c = shl i32 %b, 4
+ %q = ashr i32 %c, 4
+ %d = sext i32 %q to i64
+ call void @use(i32 %b)
+ ret i64 %d
+}