From: Sanjay Patel Date: Mon, 8 Jul 2019 14:49:21 +0000 (+0000) Subject: [InstCombine] add tests for splat shuffles; NFC X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4fa3098716a1b6377d44bc0188475795b7123222;p=llvm [InstCombine] add tests for splat shuffles; NFC git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@365325 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/Transforms/InstCombine/insert-extract-shuffle.ll b/test/Transforms/InstCombine/insert-extract-shuffle.ll index 2de9c66d463..e6fc0129614 100644 --- a/test/Transforms/InstCombine/insert-extract-shuffle.ll +++ b/test/Transforms/InstCombine/insert-extract-shuffle.ll @@ -425,3 +425,46 @@ define <5 x float> @insert_not_undef_shuffle_translate_commute_lengthen(float %x ret <5 x float> %r } +define <4 x float> @insert_nonzero_index_splat(float %x) { +; CHECK-LABEL: @insert_nonzero_index_splat( +; CHECK-NEXT: [[XV:%.*]] = insertelement <4 x float> undef, float [[X:%.*]], i32 2 +; CHECK-NEXT: [[SPLAT:%.*]] = shufflevector <4 x float> [[XV]], <4 x float> undef, <4 x i32> +; CHECK-NEXT: ret <4 x float> [[SPLAT]] +; + %xv = insertelement <4 x float> undef, float %x, i32 2 + %splat = shufflevector <4 x float> %xv, <4 x float> undef, <4 x i32> + ret <4 x float> %splat +} + +define <3 x double> @insert_nonzero_index_splat_narrow(double %x) { +; CHECK-LABEL: @insert_nonzero_index_splat_narrow( +; CHECK-NEXT: ret <3 x double> undef +; + %xv = insertelement <4 x double> undef, double %x, i32 4 + %splat = shufflevector <4 x double> %xv, <4 x double> undef, <3 x i32> + ret <3 x double> %splat +} + +define <5 x i7> @insert_nonzero_index_splat_widen(i7 %x) { +; CHECK-LABEL: @insert_nonzero_index_splat_widen( +; CHECK-NEXT: [[XV:%.*]] = insertelement <4 x i7> undef, i7 [[X:%.*]], i32 1 +; CHECK-NEXT: [[SPLAT:%.*]] = shufflevector <4 x i7> [[XV]], <4 x i7> undef, <5 x i32> +; CHECK-NEXT: ret <5 x i7> [[SPLAT]] +; + %xv = insertelement <4 x i7> undef, i7 %x, i32 1 + %splat = shufflevector <4 x i7> %xv, <4 x i7> undef, <5 x i32> + ret <5 x i7> %splat +} + +define <4 x float> @insert_nonzero_index_splat_extra_use(float %x) { +; CHECK-LABEL: @insert_nonzero_index_splat_extra_use( +; CHECK-NEXT: [[XV:%.*]] = insertelement <4 x float> undef, float [[X:%.*]], i32 2 +; CHECK-NEXT: call void @use(<4 x float> [[XV]]) +; CHECK-NEXT: [[SPLAT:%.*]] = shufflevector <4 x float> [[XV]], <4 x float> undef, <4 x i32> +; CHECK-NEXT: ret <4 x float> [[SPLAT]] +; + %xv = insertelement <4 x float> undef, float %x, i32 2 + call void @use(<4 x float> %xv) + %splat = shufflevector <4 x float> %xv, <4 x float> undef, <4 x i32> + ret <4 x float> %splat +}