OSDN Git Service

[InstCombine] add tests for trunc(shuffle X, C, M); NFC
authorSanjay Patel <spatel@rotateright.com>
Fri, 17 Feb 2017 23:16:54 +0000 (23:16 +0000)
committerSanjay Patel <spatel@rotateright.com>
Fri, 17 Feb 2017 23:16:54 +0000 (23:16 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295513 91177308-0d34-0410-b5e6-96231b3b80d8

test/Transforms/InstCombine/trunc.ll

index eaa45bb..1da4f42 100644 (file)
@@ -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_4(<8 x i32> %a) {
   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
+}
+