[llvm] 5eeea33 - [VectorCombine] add more tests for extract-extract patterns; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 23 06:34:05 PDT 2020
Author: Sanjay Patel
Date: 2020-03-23T09:33:56-04:00
New Revision: 5eeea337bec32b57b53f533da59e61af71c8518d
URL: https://github.com/llvm/llvm-project/commit/5eeea337bec32b57b53f533da59e61af71c8518d
DIFF: https://github.com/llvm/llvm-project/commit/5eeea337bec32b57b53f533da59e61af71c8518d.diff
LOG: [VectorCombine] add more tests for extract-extract patterns; NFC
Added:
Modified:
llvm/test/Transforms/VectorCombine/X86/extract-binop.ll
llvm/test/Transforms/VectorCombine/X86/extract-cmp.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/VectorCombine/X86/extract-binop.ll b/llvm/test/Transforms/VectorCombine/X86/extract-binop.ll
index 56635bdff8c5..cc3d35ff9d71 100644
--- a/llvm/test/Transforms/VectorCombine/X86/extract-binop.ll
+++ b/llvm/test/Transforms/VectorCombine/X86/extract-binop.ll
@@ -415,3 +415,71 @@ define float @ext14_ext15_fmul_v16f32(<16 x float> %x) {
%r = fadd float %e0, %e1
ret float %r
}
+
+define <4 x float> @ins_bo_ext_ext(<4 x float> %a, <4 x float> %b) {
+; CHECK-LABEL: @ins_bo_ext_ext(
+; CHECK-NEXT: [[TMP1:%.*]] = shufflevector <4 x float> [[A:%.*]], <4 x float> undef, <4 x i32> <i32 undef, i32 undef, i32 3, i32 undef>
+; CHECK-NEXT: [[TMP2:%.*]] = fadd <4 x float> [[A]], [[TMP1]]
+; CHECK-NEXT: [[TMP3:%.*]] = extractelement <4 x float> [[TMP2]], i32 2
+; CHECK-NEXT: [[V3:%.*]] = insertelement <4 x float> [[B:%.*]], float [[TMP3]], i32 3
+; CHECK-NEXT: ret <4 x float> [[V3]]
+;
+ %a2 = extractelement <4 x float> %a, i32 2
+ %a3 = extractelement <4 x float> %a, i32 3
+ %a23 = fadd float %a2, %a3
+ %v3 = insertelement <4 x float> %b, float %a23, i32 3
+ ret <4 x float> %v3
+}
+
+define <4 x float> @ins_bo_ext_ext_uses(<4 x float> %a, <4 x float> %b) {
+; CHECK-LABEL: @ins_bo_ext_ext_uses(
+; CHECK-NEXT: [[TMP1:%.*]] = shufflevector <4 x float> [[A:%.*]], <4 x float> undef, <4 x i32> <i32 undef, i32 undef, i32 3, i32 undef>
+; CHECK-NEXT: [[TMP2:%.*]] = fadd <4 x float> [[A]], [[TMP1]]
+; CHECK-NEXT: [[TMP3:%.*]] = extractelement <4 x float> [[TMP2]], i32 2
+; CHECK-NEXT: call void @use_f32(float [[TMP3]])
+; CHECK-NEXT: [[V3:%.*]] = insertelement <4 x float> [[B:%.*]], float [[TMP3]], i32 3
+; CHECK-NEXT: ret <4 x float> [[V3]]
+;
+ %a2 = extractelement <4 x float> %a, i32 2
+ %a3 = extractelement <4 x float> %a, i32 3
+ %a23 = fadd float %a2, %a3
+ call void @use_f32(float %a23)
+ %v3 = insertelement <4 x float> %b, float %a23, i32 3
+ ret <4 x float> %v3
+}
+
+define <4 x float> @PR34724(<4 x float> %a, <4 x float> %b) {
+; CHECK-LABEL: @PR34724(
+; CHECK-NEXT: [[TMP1:%.*]] = shufflevector <4 x float> [[A:%.*]], <4 x float> undef, <4 x i32> <i32 undef, i32 undef, i32 3, i32 undef>
+; CHECK-NEXT: [[TMP2:%.*]] = shufflevector <4 x float> [[B:%.*]], <4 x float> undef, <4 x i32> <i32 1, i32 undef, i32 undef, i32 undef>
+; CHECK-NEXT: [[TMP3:%.*]] = shufflevector <4 x float> [[B]], <4 x float> undef, <4 x i32> <i32 undef, i32 undef, i32 3, i32 undef>
+; CHECK-NEXT: [[TMP4:%.*]] = fadd <4 x float> [[A]], [[TMP1]]
+; CHECK-NEXT: [[TMP5:%.*]] = extractelement <4 x float> [[TMP4]], i32 2
+; CHECK-NEXT: [[TMP6:%.*]] = fadd <4 x float> [[B]], [[TMP2]]
+; CHECK-NEXT: [[TMP7:%.*]] = extractelement <4 x float> [[TMP6]], i32 0
+; CHECK-NEXT: [[TMP8:%.*]] = fadd <4 x float> [[B]], [[TMP3]]
+; CHECK-NEXT: [[TMP9:%.*]] = extractelement <4 x float> [[TMP8]], i32 2
+; CHECK-NEXT: [[V1:%.*]] = insertelement <4 x float> undef, float [[TMP5]], i32 1
+; CHECK-NEXT: [[V2:%.*]] = insertelement <4 x float> [[V1]], float [[TMP7]], i32 2
+; CHECK-NEXT: [[V3:%.*]] = insertelement <4 x float> [[V2]], float [[TMP9]], i32 3
+; CHECK-NEXT: ret <4 x float> [[V3]]
+;
+ %a0 = extractelement <4 x float> %a, i32 0
+ %a1 = extractelement <4 x float> %a, i32 1
+ %a2 = extractelement <4 x float> %a, i32 2
+ %a3 = extractelement <4 x float> %a, i32 3
+
+ %b0 = extractelement <4 x float> %b, i32 0
+ %b1 = extractelement <4 x float> %b, i32 1
+ %b2 = extractelement <4 x float> %b, i32 2
+ %b3 = extractelement <4 x float> %b, i32 3
+
+ %a23 = fadd float %a2, %a3
+ %b01 = fadd float %b0, %b1
+ %b23 = fadd float %b2, %b3
+
+ %v1 = insertelement <4 x float> undef, float %a23, i32 1
+ %v2 = insertelement <4 x float> %v1, float %b01, i32 2
+ %v3 = insertelement <4 x float> %v2, float %b23, i32 3
+ ret <4 x float> %v3
+}
diff --git a/llvm/test/Transforms/VectorCombine/X86/extract-cmp.ll b/llvm/test/Transforms/VectorCombine/X86/extract-cmp.ll
index 65d886c7bca9..807bb800e997 100644
--- a/llvm/test/Transforms/VectorCombine/X86/extract-cmp.ll
+++ b/llvm/test/Transforms/VectorCombine/X86/extract-cmp.ll
@@ -151,3 +151,40 @@ define i1 @cmp12_v4i32(<4 x i32> %x, <4 x i32> %y) {
%cmp = icmp sgt i32 %x1, %y2
ret i1 %cmp
}
+
+define <4 x i1> @ins_fcmp_ext_ext(<4 x float> %a, <4 x i1> %b) {
+; SSE-LABEL: @ins_fcmp_ext_ext(
+; SSE-NEXT: [[A1:%.*]] = extractelement <4 x float> [[A:%.*]], i32 1
+; SSE-NEXT: [[A2:%.*]] = extractelement <4 x float> [[A]], i32 2
+; SSE-NEXT: [[A21:%.*]] = fcmp ugt float [[A2]], [[A1]]
+; SSE-NEXT: [[R:%.*]] = insertelement <4 x i1> [[B:%.*]], i1 [[A21]], i32 2
+; SSE-NEXT: ret <4 x i1> [[R]]
+;
+; AVX-LABEL: @ins_fcmp_ext_ext(
+; AVX-NEXT: [[TMP1:%.*]] = shufflevector <4 x float> [[A:%.*]], <4 x float> undef, <4 x i32> <i32 undef, i32 2, i32 undef, i32 undef>
+; AVX-NEXT: [[TMP2:%.*]] = fcmp ugt <4 x float> [[TMP1]], [[A]]
+; AVX-NEXT: [[TMP3:%.*]] = extractelement <4 x i1> [[TMP2]], i64 1
+; AVX-NEXT: [[R:%.*]] = insertelement <4 x i1> [[B:%.*]], i1 [[TMP3]], i32 2
+; AVX-NEXT: ret <4 x i1> [[R]]
+;
+ %a1 = extractelement <4 x float> %a, i32 1
+ %a2 = extractelement <4 x float> %a, i32 2
+ %a21 = fcmp ugt float %a2, %a1
+ %r = insertelement <4 x i1> %b, i1 %a21, i32 2
+ ret <4 x i1> %r
+}
+
+define <4 x i1> @ins_icmp_ext_ext(<4 x i32> %a, <4 x i1> %b) {
+; CHECK-LABEL: @ins_icmp_ext_ext(
+; CHECK-NEXT: [[TMP1:%.*]] = shufflevector <4 x i32> [[A:%.*]], <4 x i32> undef, <4 x i32> <i32 undef, i32 undef, i32 3, i32 undef>
+; CHECK-NEXT: [[TMP2:%.*]] = icmp ule <4 x i32> [[A]], [[TMP1]]
+; CHECK-NEXT: [[TMP3:%.*]] = extractelement <4 x i1> [[TMP2]], i32 2
+; CHECK-NEXT: [[R:%.*]] = insertelement <4 x i1> [[B:%.*]], i1 [[TMP3]], i32 3
+; CHECK-NEXT: ret <4 x i1> [[R]]
+;
+ %a3 = extractelement <4 x i32> %a, i32 3
+ %a2 = extractelement <4 x i32> %a, i32 2
+ %a23 = icmp ule i32 %a2, %a3
+ %r = insertelement <4 x i1> %b, i1 %a23, i32 3
+ ret <4 x i1> %r
+}
More information about the llvm-commits
mailing list