From: Sanjay Patel Date: Sat, 18 Feb 2017 15:24:31 +0000 (+0000) Subject: [InstCombine] update trunc(shuffle) tests to reflect IR reality; NFC X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=de80e80f011507c5c936964c6ab2dc0fa3766f4a;p=llvm [InstCombine] update trunc(shuffle) tests to reflect IR reality; NFC We're ok shrinking splats, but not shuffles in general. See https://reviews.llvm.org/D30123 for discussion. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295547 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/Transforms/InstCombine/trunc.ll b/test/Transforms/InstCombine/trunc.ll index 1da4f42ccc4..581e990df0f 100644 --- a/test/Transforms/InstCombine/trunc.ll +++ b/test/Transforms/InstCombine/trunc.ll @@ -464,10 +464,11 @@ 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 +; Although the mask is the same value, we don't create a shuffle for types that the backend may not be able to handle: +; trunc (shuffle X, C, Mask) --> shuffle (trunc X), C', Mask -define <4 x i8> @shuf1(<4 x i32> %x) { -; CHECK-LABEL: @shuf1( +define <4 x i8> @wide_shuf(<4 x i32> %x) { +; CHECK-LABEL: @wide_shuf( ; CHECK-NEXT: [[SHUF:%.*]] = shufflevector <4 x i32> %x, <4 x i32> , <4 x i32> ; CHECK-NEXT: [[TRUNC:%.*]] = trunc <4 x i32> [[SHUF]] to <4 x i8> ; CHECK-NEXT: ret <4 x i8> [[TRUNC]] @@ -477,17 +478,47 @@ define <4 x i8> @shuf1(<4 x i32> %x) { 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 +; FIXME: +; trunc (shuffle X, undef, SplatMask) --> shuffle (trunc X), undef, SplatMask -define <4 x i8> @shuf2(<4 x i32> %x) { -; CHECK-LABEL: @shuf2( -; CHECK-NEXT: [[SHUF:%.*]] = shufflevector <4 x i32> , <4 x i32> %x, <4 x i32> +define <4 x i8> @wide_splat1(<4 x i32> %x) { +; CHECK-LABEL: @wide_splat1( +; CHECK-NEXT: [[SHUF:%.*]] = shufflevector <4 x i32> %x, <4 x i32> undef, <4 x i32> ; CHECK-NEXT: [[TRUNC:%.*]] = trunc <4 x i32> [[SHUF]] to <4 x i8> ; CHECK-NEXT: ret <4 x i8> [[TRUNC]] ; - %shuf = shufflevector <4 x i32> , <4 x i32> %x, <4 x i32> + %shuf = shufflevector <4 x i32> %x, <4 x i32> undef, <4 x i32> %trunc = trunc <4 x i32> %shuf to <4 x i8> ret <4 x i8> %trunc } +; FIXME: +; Test weird types. +; trunc (shuffle X, undef, SplatMask) --> shuffle (trunc X), undef, SplatMask + +define <3 x i31> @wide_splat2(<3 x i33> %x) { +; CHECK-LABEL: @wide_splat2( +; CHECK-NEXT: [[SHUF:%.*]] = shufflevector <3 x i33> %x, <3 x i33> undef, <3 x i32> +; CHECK-NEXT: [[TRUNC:%.*]] = trunc <3 x i33> [[SHUF]] to <3 x i31> +; CHECK-NEXT: ret <3 x i31> [[TRUNC]] +; + %shuf = shufflevector <3 x i33> %x, <3 x i33> undef, <3 x i32> + %trunc = trunc <3 x i33> %shuf to <3 x i31> + ret <3 x i31> %trunc +} + +; FIXME: +; trunc (shuffle X, undef, SplatMask) --> shuffle (trunc X), undef, SplatMask +; A mask with undef elements should still be considered a splat mask. + +define <3 x i31> @wide_splat3(<3 x i33> %x) { +; CHECK-LABEL: @wide_splat3( +; CHECK-NEXT: [[SHUF:%.*]] = shufflevector <3 x i33> %x, <3 x i33> undef, <3 x i32> +; CHECK-NEXT: [[TRUNC:%.*]] = trunc <3 x i33> [[SHUF]] to <3 x i31> +; CHECK-NEXT: ret <3 x i31> [[TRUNC]] +; + %shuf = shufflevector <3 x i33> %x, <3 x i33> undef, <3 x i32> + %trunc = trunc <3 x i33> %shuf to <3 x i31> + ret <3 x i31> %trunc +} +