[llvm] r253609 - [InstCombine] add tests to show missing trunc optimizations

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 19 14:11:52 PST 2015


Author: spatel
Date: Thu Nov 19 16:11:52 2015
New Revision: 253609

URL: http://llvm.org/viewvc/llvm-project?rev=253609&view=rev
Log:
[InstCombine] add tests to show missing trunc optimizations

Modified:
    llvm/trunk/test/Transforms/InstCombine/trunc.ll

Modified: llvm/trunk/test/Transforms/InstCombine/trunc.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/trunc.ll?rev=253609&r1=253608&r2=253609&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/trunc.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/trunc.ll Thu Nov 19 16:11:52 2015
@@ -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
+}
+




More information about the llvm-commits mailing list