From c185ca148d516c9694aef31c79efa09bb585cb54 Mon Sep 17 00:00:00 2001 From: Sanjay Patel Date: Tue, 21 May 2019 21:45:24 +0000 Subject: [PATCH] [InstCombine] add more tests for shuffle folding; NFC As discussed in D62024, we want to limit any potential IR transforms of shuffles to cases where we know the SDAG conversion would result in equivalent patterns for these IR variants. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@361317 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/Transforms/InstCombine/vec_shuffle.ll | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/test/Transforms/InstCombine/vec_shuffle.ll b/test/Transforms/InstCombine/vec_shuffle.ll index 0d8296086b7..821c0829076 100644 --- a/test/Transforms/InstCombine/vec_shuffle.ll +++ b/test/Transforms/InstCombine/vec_shuffle.ll @@ -1153,6 +1153,19 @@ define <7 x i8> @insert_subvector_shuffles(<3 x i8> %x, <3 x i8> %y) { ret <7 x i8> %s3 } +define <8 x i8> @insert_subvector_shuffles_pow2elts(<2 x i8> %x, <2 x i8> %y) { +; CHECK-LABEL: @insert_subvector_shuffles_pow2elts( +; CHECK-NEXT: [[S1:%.*]] = shufflevector <2 x i8> [[X:%.*]], <2 x i8> undef, <8 x i32> +; CHECK-NEXT: [[S2:%.*]] = shufflevector <2 x i8> [[Y:%.*]], <2 x i8> undef, <8 x i32> +; CHECK-NEXT: [[S3:%.*]] = shufflevector <8 x i8> [[S1]], <8 x i8> [[S2]], <8 x i32> +; CHECK-NEXT: ret <8 x i8> [[S3]] +; + %s1 = shufflevector <2 x i8> %x, <2 x i8> undef, <8 x i32> + %s2 = shufflevector <2 x i8> %y, <2 x i8> undef, <8 x i32> + %s3 = shufflevector <8 x i8> %s1, <8 x i8> %s2, <8 x i32> + ret <8 x i8> %s3 +} + ; The last shuffle may change the vector type. define <2 x i8> @insert_subvector_shuffles_narrowing(<3 x i8> %x, <3 x i8> %y) { @@ -1168,6 +1181,19 @@ define <2 x i8> @insert_subvector_shuffles_narrowing(<3 x i8> %x, <3 x i8> %y) { ret <2 x i8> %s3 } +define <2 x i8> @insert_subvector_shuffles_narrowing_pow2elts(<4 x i8> %x, <4 x i8> %y) { +; CHECK-LABEL: @insert_subvector_shuffles_narrowing_pow2elts( +; CHECK-NEXT: [[S1:%.*]] = shufflevector <4 x i8> [[X:%.*]], <4 x i8> undef, <8 x i32> +; CHECK-NEXT: [[S2:%.*]] = shufflevector <4 x i8> [[Y:%.*]], <4 x i8> undef, <8 x i32> +; CHECK-NEXT: [[S3:%.*]] = shufflevector <8 x i8> [[S1]], <8 x i8> [[S2]], <2 x i32> +; CHECK-NEXT: ret <2 x i8> [[S3]] +; + %s1 = shufflevector <4 x i8> %x, <4 x i8> undef, <8 x i32> + %s2 = shufflevector <4 x i8> %y, <4 x i8> undef, <8 x i32> + %s3 = shufflevector <8 x i8> %s1, <8 x i8> %s2, <2 x i32> + ret <2 x i8> %s3 +} + ; Similar to above, but this reduces to a widen with undefs of 'x'. define <4 x double> @insert_subvector_shuffles_identity(<2 x double> %x) { -- 2.40.0