[llvm] r295513 - [InstCombine] add tests for trunc(shuffle X, C, M); NFC

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 17 15:16:54 PST 2017


Author: spatel
Date: Fri Feb 17 17:16:54 2017
New Revision: 295513

URL: http://llvm.org/viewvc/llvm-project?rev=295513&view=rev
Log:
[InstCombine] add tests for trunc(shuffle X, C, M); NFC

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=295513&r1=295512&r2=295513&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/trunc.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/trunc.ll Fri Feb 17 17:16:54 2017
@@ -119,8 +119,8 @@ define i64 @test8(i32 %A, i32 %B) {
 
 define i8 @test9(i32 %X) {
 ; CHECK-LABEL: @test9(
-; CHECK-NEXT:    [[X_TR:%.*]] = trunc i32 %X to i8
-; CHECK-NEXT:    [[Z:%.*]] = and i8 [[X_TR]], 42
+; CHECK-NEXT:    [[TMP1:%.*]] = trunc i32 %X to i8
+; CHECK-NEXT:    [[Z:%.*]] = and i8 [[TMP1]], 42
 ; CHECK-NEXT:    ret i8 [[Z]]
 ;
   %Y = and i32 %X, 42
@@ -464,3 +464,30 @@ define <8 x i16> @trunc_shl_v8i16_v8i32_
   ret <8 x i16> %conv
 }
 
+; FIXME: trunc (shuffle X, C, Mask) --> shuffle (trunc X), C', Mask
+
+define <4 x i8> @shuf1(<4 x i32> %x) {
+; CHECK-LABEL: @shuf1(
+; CHECK-NEXT:    [[SHUF:%.*]] = shufflevector <4 x i32> %x, <4 x i32> <i32 undef, i32 3634, i32 90, i32 undef>, <4 x i32> <i32 1, i32 5, i32 6, i32 2>
+; CHECK-NEXT:    [[TRUNC:%.*]] = trunc <4 x i32> [[SHUF]] to <4 x i8>
+; CHECK-NEXT:    ret <4 x i8> [[TRUNC]]
+;
+  %shuf = shufflevector <4 x i32> %x, <4 x i32> <i32 35, i32 3634, i32 90, i32 -1>, <4 x i32> <i32 1, i32 5, i32 6, i32 2>
+  %trunc = trunc <4 x i32> %shuf to <4 x i8>
+  ret <4 x i8> %trunc
+}
+
+; TODO: Shuffle with constant operand should be canonicalized to operand 1?
+; FIXME: trunc (shuffle C, X, Mask) --> shuffle C', (trunc X), Mask
+
+define <4 x i8> @shuf2(<4 x i32> %x) {
+; CHECK-LABEL: @shuf2(
+; CHECK-NEXT:    [[SHUF:%.*]] = shufflevector <4 x i32> <i32 -3500, i32 undef, i32 undef, i32 -1>, <4 x i32> %x, <4 x i32> <i32 3, i32 6, i32 6, i32 0>
+; CHECK-NEXT:    [[TRUNC:%.*]] = trunc <4 x i32> [[SHUF]] to <4 x i8>
+; CHECK-NEXT:    ret <4 x i8> [[TRUNC]]
+;
+  %shuf = shufflevector <4 x i32> <i32 -3500, i32 3634, i32 90, i32 -1>, <4 x i32> %x, <4 x i32> <i32 3, i32 6, i32 6, i32 0>
+  %trunc = trunc <4 x i32> %shuf to <4 x i8>
+  ret <4 x i8> %trunc
+}
+




More information about the llvm-commits mailing list