diff options
author | Sanjay Patel <spatel@rotateright.com> | 2019-12-10 11:16:47 -0500 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2019-12-10 17:16:58 -0500 |
commit | 252d3b9805f8064837630deb282f653ac2978096 (patch) | |
tree | ca2e83bc5a8ffdfcf844a6599bce2674ba7b47ec | |
parent | 4ffd3f44e34283506958263a7f9eb2c9d149087f (diff) | |
download | bcm5719-llvm-252d3b9805f8064837630deb282f653ac2978096.tar.gz bcm5719-llvm-252d3b9805f8064837630deb282f653ac2978096.zip |
[InstSimplify] add tests for insert constant + splat; NFC
-rw-r--r-- | llvm/test/Transforms/InstCombine/insert-extract-shuffle.ll | 13 | ||||
-rw-r--r-- | llvm/test/Transforms/InstSimplify/shufflevector.ll | 22 |
2 files changed, 35 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstCombine/insert-extract-shuffle.ll b/llvm/test/Transforms/InstCombine/insert-extract-shuffle.ll index fe000572963..83fd7b6129e 100644 --- a/llvm/test/Transforms/InstCombine/insert-extract-shuffle.ll +++ b/llvm/test/Transforms/InstCombine/insert-extract-shuffle.ll @@ -721,3 +721,16 @@ define <4 x float> @insert_demanded_element_op1(<4 x float> %x, <4 x float> %y) %s = shufflevector <4 x float> %y, <4 x float> %ins, <4 x i32> <i32 0, i32 7, i32 1, i32 4> ret <4 x float> %s } + +define <4 x float> @splat_constant(<4 x float> %x) { +; CHECK-LABEL: @splat_constant( +; CHECK-NEXT: [[INS3:%.*]] = insertelement <4 x float> [[X:%.*]], float 3.000000e+00, i32 3 +; CHECK-NEXT: [[SPLAT3:%.*]] = shufflevector <4 x float> [[INS3]], <4 x float> undef, <4 x i32> <i32 3, i32 3, i32 3, i32 3> +; CHECK-NEXT: [[R:%.*]] = fadd <4 x float> [[INS3]], [[SPLAT3]] +; CHECK-NEXT: ret <4 x float> [[R]] +; + %ins3 = insertelement <4 x float> %x, float 3.0, i32 3 + %splat3 = shufflevector <4 x float> %ins3, <4 x float> undef, <4 x i32> <i32 3, i32 3, i32 3, i32 3> + %r = fadd <4 x float> %ins3, %splat3 + ret <4 x float> %r +} diff --git a/llvm/test/Transforms/InstSimplify/shufflevector.ll b/llvm/test/Transforms/InstSimplify/shufflevector.ll index cc49ae3554c..6ffd4f004c2 100644 --- a/llvm/test/Transforms/InstSimplify/shufflevector.ll +++ b/llvm/test/Transforms/InstSimplify/shufflevector.ll @@ -247,3 +247,25 @@ define <2 x float> @PR32872(<2 x float> %x) { %tmp4 = shufflevector <4 x float> zeroinitializer, <4 x float> %tmp1, <2 x i32> <i32 4, i32 5> ret <2 x float> %tmp4 } + +define <4 x float> @splat_constant(<4 x float> %x) { +; CHECK-LABEL: @splat_constant( +; CHECK-NEXT: [[INS3:%.*]] = insertelement <4 x float> [[X:%.*]], float 4.200000e+01, i32 3 +; CHECK-NEXT: [[SPLAT3:%.*]] = shufflevector <4 x float> [[INS3]], <4 x float> undef, <4 x i32> <i32 3, i32 3, i32 3, i32 3> +; CHECK-NEXT: ret <4 x float> [[SPLAT3]] +; + %ins3 = insertelement <4 x float> %x, float 42.0, i32 3 + %splat3 = shufflevector <4 x float> %ins3, <4 x float> undef, <4 x i32> <i32 3, i32 3, i32 3, i32 3> + ret <4 x float> %splat3 +} + +define <4 x float> @splat_constant_undef_elt(<4 x float> %x) { +; CHECK-LABEL: @splat_constant_undef_elt( +; CHECK-NEXT: [[INS1:%.*]] = insertelement <4 x float> [[X:%.*]], float 1.200000e+01, i32 1 +; CHECK-NEXT: [[SPLAT1:%.*]] = shufflevector <4 x float> [[INS1]], <4 x float> undef, <4 x i32> <i32 1, i32 1, i32 undef, i32 1> +; CHECK-NEXT: ret <4 x float> [[SPLAT1]] +; + %ins1 = insertelement <4 x float> %x, float 12.0, i32 1 + %splat1 = shufflevector <4 x float> %ins1, <4 x float> undef, <4 x i32> <i32 1, i32 1, i32 undef, i32 1> + ret <4 x float> %splat1 +} |