[llvm] 252d3b9 - [InstSimplify] add tests for insert constant + splat; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 10 14:17:12 PST 2019
Author: Sanjay Patel
Date: 2019-12-10T17:16:58-05:00
New Revision: 252d3b9805f8064837630deb282f653ac2978096
URL: https://github.com/llvm/llvm-project/commit/252d3b9805f8064837630deb282f653ac2978096
DIFF: https://github.com/llvm/llvm-project/commit/252d3b9805f8064837630deb282f653ac2978096.diff
LOG: [InstSimplify] add tests for insert constant + splat; NFC
Added:
Modified:
llvm/test/Transforms/InstCombine/insert-extract-shuffle.ll
llvm/test/Transforms/InstSimplify/shufflevector.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstCombine/insert-extract-shuffle.ll b/llvm/test/Transforms/InstCombine/insert-extract-shuffle.ll
index fe0005729630..83fd7b6129ee 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 cc49ae3554c0..6ffd4f004c21 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
+}
More information about the llvm-commits
mailing list