From 6568ffbaea34e8fcd47f1cbf8ec76b6d0090090e Mon Sep 17 00:00:00 2001 From: Sanjay Patel Date: Mon, 8 Jul 2019 18:03:22 +0000 Subject: [PATCH] [InstCombine] add tests for insert of same splatted scalar; NFC git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@365362 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../InstCombine/insert-extract-shuffle.ll | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/test/Transforms/InstCombine/insert-extract-shuffle.ll b/test/Transforms/InstCombine/insert-extract-shuffle.ll index a1f7fca80c3..7603298c26c 100644 --- a/test/Transforms/InstCombine/insert-extract-shuffle.ll +++ b/test/Transforms/InstCombine/insert-extract-shuffle.ll @@ -498,3 +498,72 @@ define <4 x float> @insert_nonzero_index_splat_wrong_index(float %x, i32 %index) %splat = shufflevector <4 x float> %xv, <4 x float> undef, <4 x i32> ret <4 x float> %splat } + +define <4 x float> @insert_in_splat(float %x) { +; CHECK-LABEL: @insert_in_splat( +; CHECK-NEXT: [[XV:%.*]] = insertelement <4 x float> undef, float [[X:%.*]], i32 0 +; CHECK-NEXT: [[SPLAT:%.*]] = shufflevector <4 x float> [[XV]], <4 x float> undef, <4 x i32> +; CHECK-NEXT: [[R:%.*]] = insertelement <4 x float> [[SPLAT]], float [[X]], i32 3 +; CHECK-NEXT: ret <4 x float> [[R]] +; + %xv = insertelement <4 x float> undef, float %x, i32 0 + %splat = shufflevector <4 x float> %xv, <4 x float> undef, <4 x i32> + %r = insertelement <4 x float> %splat, float %x, i32 3 + ret <4 x float> %r +} + +define <4 x float> @insert_in_splat_extra_uses(float %x) { +; CHECK-LABEL: @insert_in_splat_extra_uses( +; CHECK-NEXT: [[XV:%.*]] = insertelement <4 x float> undef, float [[X:%.*]], i32 0 +; 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: call void @use(<4 x float> [[SPLAT]]) +; CHECK-NEXT: [[R:%.*]] = insertelement <4 x float> [[SPLAT]], float [[X]], i32 3 +; CHECK-NEXT: ret <4 x float> [[R]] +; + %xv = insertelement <4 x float> undef, float %x, i32 0 + call void @use(<4 x float> %xv) + %splat = shufflevector <4 x float> %xv, <4 x float> undef, <4 x i32> + call void @use(<4 x float> %splat) + %r = insertelement <4 x float> %splat, float %x, i32 3 + ret <4 x float> %r +} + +define <4 x float> @insert_in_splat_variable_index(float %x, i32 %y) { +; CHECK-LABEL: @insert_in_splat_variable_index( +; CHECK-NEXT: [[XV:%.*]] = insertelement <4 x float> undef, float [[X:%.*]], i32 0 +; CHECK-NEXT: [[SPLAT:%.*]] = shufflevector <4 x float> [[XV]], <4 x float> undef, <4 x i32> +; CHECK-NEXT: [[R:%.*]] = insertelement <4 x float> [[SPLAT]], float [[X]], i32 [[Y:%.*]] +; CHECK-NEXT: ret <4 x float> [[R]] +; + %xv = insertelement <4 x float> undef, float %x, i32 0 + %splat = shufflevector <4 x float> %xv, <4 x float> undef, <4 x i32> + %r = insertelement <4 x float> %splat, float %x, i32 %y + ret <4 x float> %r +} + +define <4 x float> @insert_in_nonsplat(float %x, <4 x float> %y) { +; CHECK-LABEL: @insert_in_nonsplat( +; CHECK-NEXT: [[XV:%.*]] = insertelement <4 x float> undef, float [[X:%.*]], i32 0 +; CHECK-NEXT: [[SPLAT:%.*]] = shufflevector <4 x float> [[XV]], <4 x float> [[Y:%.*]], <4 x i32> +; CHECK-NEXT: [[R:%.*]] = insertelement <4 x float> [[SPLAT]], float [[X]], i32 3 +; CHECK-NEXT: ret <4 x float> [[R]] +; + %xv = insertelement <4 x float> undef, float %x, i32 0 + %splat = shufflevector <4 x float> %xv, <4 x float> %y, <4 x i32> + %r = insertelement <4 x float> %splat, float %x, i32 3 + ret <4 x float> %r +} + +define <4 x float> @insert_in_nonsplat2(float %x, <4 x float> %y) { +; CHECK-LABEL: @insert_in_nonsplat2( +; CHECK-NEXT: [[XV:%.*]] = insertelement <4 x float> [[Y:%.*]], float [[X:%.*]], i32 0 +; CHECK-NEXT: [[SPLAT:%.*]] = shufflevector <4 x float> [[XV]], <4 x float> undef, <4 x i32> +; CHECK-NEXT: [[R:%.*]] = insertelement <4 x float> [[SPLAT]], float [[X]], i32 3 +; CHECK-NEXT: ret <4 x float> [[R]] +; + %xv = insertelement <4 x float> %y, float %x, i32 0 + %splat = shufflevector <4 x float> %xv, <4 x float> undef, <4 x i32> + %r = insertelement <4 x float> %splat, float %x, i32 3 + ret <4 x float> %r +} -- 2.50.1