summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2015-11-19 22:11:52 +0000
committerSanjay Patel <spatel@rotateright.com>2015-11-19 22:11:52 +0000
commitc4aa50414b2c8b9af08f49e164bedcd1c6374d1e (patch)
tree4a62672906714e0f9ad5437ed65e4f1de2fadffb
parent145e4d64713eee6b62698369b584b33e83a87970 (diff)
downloadbcm5719-llvm-c4aa50414b2c8b9af08f49e164bedcd1c6374d1e.tar.gz
bcm5719-llvm-c4aa50414b2c8b9af08f49e164bedcd1c6374d1e.zip
[InstCombine] add tests to show missing trunc optimizations
llvm-svn: 253609
-rw-r--r--llvm/test/Transforms/InstCombine/trunc.ll46
1 files changed, 46 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstCombine/trunc.ll b/llvm/test/Transforms/InstCombine/trunc.ll
index ee81cf8c3c5..7c30f100b3e 100644
--- a/llvm/test/Transforms/InstCombine/trunc.ll
+++ b/llvm/test/Transforms/InstCombine/trunc.ll
@@ -118,3 +118,49 @@ define i8 @test10(i32 %X) {
; CHECK: and
; CHECK: ret
}
+
+; PR25543
+; https://llvm.org/bugs/show_bug.cgi?id=25543
+; TODO: This could be extractelement.
+
+define i32 @trunc_bitcast1(<4 x i32> %v) {
+ %bc = bitcast <4 x i32> %v to i128
+ %shr = lshr i128 %bc, 32
+ %ext = trunc i128 %shr to i32
+ ret i32 %ext
+
+; CHECK-LABEL: @trunc_bitcast1(
+; CHECK-NEXT: %bc = bitcast <4 x i32> %v to i128
+; CHECK-NEXT: %shr = lshr i128 %bc, 32
+; CHECK-NEXT: %ext = trunc i128 %shr to i32
+; CHECK-NEXT: ret i32 %ext
+}
+
+; TODO: This could be bitcast + extractelement.
+
+define i32 @trunc_bitcast2(<2 x i64> %v) {
+ %bc = bitcast <2 x i64> %v to i128
+ %shr = lshr i128 %bc, 64
+ %ext = trunc i128 %shr to i32
+ ret i32 %ext
+
+; CHECK-LABEL: @trunc_bitcast2(
+; CHECK-NEXT: %bc = bitcast <2 x i64> %v to i128
+; CHECK-NEXT: %shr = lshr i128 %bc, 64
+; CHECK-NEXT: %ext = trunc i128 %shr to i32
+; CHECK-NEXT: ret i32 %ext
+}
+
+; TODO: The shift is optional. This could be extractelement.
+
+define i32 @trunc_bitcast3(<4 x i32> %v) {
+ %bc = bitcast <4 x i32> %v to i128
+ %ext = trunc i128 %bc to i32
+ ret i32 %ext
+
+; CHECK-LABEL: @trunc_bitcast3(
+; CHECK-NEXT: %bc = bitcast <4 x i32> %v to i128
+; CHECK-NEXT: %ext = trunc i128 %bc to i32
+; CHECK-NEXT: ret i32 %ext
+}
+
OpenPOWER on IntegriCloud