summaryrefslogtreecommitdiff
path: root/test/Transforms/InstCombine/cast.ll
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-01-10 02:39:31 +0000
committerChris Lattner <sabre@nondot.org>2010-01-10 02:39:31 +0000
commit5324d802835a677888ff020174c9eab5e86d6b15 (patch)
tree8f50f562cd230060f1d19488299366e5de39bc16 /test/Transforms/InstCombine/cast.ll
parentd26c9e183e56d09f48d7074be4cacce099338316 (diff)
downloadllvm-5324d802835a677888ff020174c9eab5e86d6b15.tar.gz
llvm-5324d802835a677888ff020174c9eab5e86d6b15.tar.bz2
llvm-5324d802835a677888ff020174c9eab5e86d6b15.tar.xz
two changes:
1) don't try to optimize a sext or zext that is only used by a trunc, let the trunc get optimized first. This avoids some pointless effort in some common cases since instcombine scans down a block in the first pass. 2) Change the cost model for zext elimination to consider an 'and' cheaper than a zext. This allows us to do it more aggressively, and for the next patch to simplify the code quite a bit. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93097 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/InstCombine/cast.ll')
-rw-r--r--test/Transforms/InstCombine/cast.ll26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/Transforms/InstCombine/cast.ll b/test/Transforms/InstCombine/cast.ll
index 490df8fab6..de7f8c11f2 100644
--- a/test/Transforms/InstCombine/cast.ll
+++ b/test/Transforms/InstCombine/cast.ll
@@ -430,4 +430,30 @@ define i64 @test46(i64 %A) {
; CHECK-NEXT: ret i64 %D
}
+define i64 @test47(i8 %A) {
+ %B = sext i8 %A to i32
+ %C = or i32 %B, 42
+ %E = zext i32 %C to i64
+ ret i64 %E
+; CHECK: @test47
+; CHECK-NEXT: %B = sext i8 %A to i64
+; CHECK-NEXT: %C = or i64 %B, 42
+; CHECK-NEXT: %E = and i64 %C, 4294967295
+; CHECK-NEXT: ret i64 %E
+}
+
+define i64 @test48(i8 %A, i8 %a) {
+ %b = zext i8 %a to i32
+ %B = zext i8 %A to i32
+ %C = shl i32 %B, 8
+ %D = or i32 %C, %b
+ %E = zext i32 %D to i64
+ ret i64 %E
+; CHECK: @test48
+; CHECK-NEXT: %b = zext i8 %a to i64
+; CHECK-NEXT: %B = zext i8 %A to i64
+; CHECK-NEXT: %C = shl i64 %B, 8
+; CHECK-NEXT: %D = or i64 %C, %b
+; CHECK-NEXT: ret i64 %D
+}