[llvm] [SLP] Fix CommonMask will be transformed into an incorrect mask if createShuffle is called multiple times. (PR #124244)
Han-Kuan Chen via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 24 01:17:17 PST 2025
https://github.com/HanKuanChen created https://github.com/llvm/llvm-project/pull/124244
We have two types of mask in SLP: a scalar mask and a vector mask.
When vectorizing four i32 additions into <4 x i32>, SLP creates a mask of length 4.
When vectorizing four <2 x i32> additions into <8 x i32>, SLP also creates a mask of length 4.
We refer to the first case as a scalar mask (because the mask element represents a scalar, i32), and the second case as a vector mask (because the mask element represents a vector, <4 x i32>).
At some point, we must convert the scalar mask into a vector mask (otherwise, calling TTI cost functions or IRBuilderBase functions may yield incorrect results).
Since both ShuffleCostEstimator and ShuffleInstructionBuilder can modify the CommonMask, we have decided to perform the mask transformation only within createShuffle. However, we do not store the transformed result, as createShuffle may be called multiple times.
>From 81c2cc17030d6876de8daa479a267045196621e6 Mon Sep 17 00:00:00 2001
From: Han-Kuan Chen <hankuan.chen at sifive.com>
Date: Wed, 18 Dec 2024 02:07:30 -0800
Subject: [PATCH 1/3] [SLP][REVEC] Pre-commit test.
---
.../Transforms/SLPVectorizer/RISCV/revec.ll | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/llvm/test/Transforms/SLPVectorizer/RISCV/revec.ll b/llvm/test/Transforms/SLPVectorizer/RISCV/revec.ll
index 61ff4f5766d309..4267828d42e3d0 100644
--- a/llvm/test/Transforms/SLPVectorizer/RISCV/revec.ll
+++ b/llvm/test/Transforms/SLPVectorizer/RISCV/revec.ll
@@ -231,3 +231,21 @@ define ptr @test4() {
%28 = tail call float @llvm.sqrt.f32(float %26)
ret ptr null
}
+
+define i32 @test5() {
+entry:
+ %div0 = fdiv <2 x double> zeroinitializer, zeroinitializer
+ %div1 = fdiv <2 x double> zeroinitializer, zeroinitializer
+ %add0 = fadd <2 x double> zeroinitializer, %div0
+ %add1 = fadd <2 x double> zeroinitializer, zeroinitializer
+ %add2 = fadd <2 x double> %div1, zeroinitializer
+ %add3 = fadd <2 x double> zeroinitializer, zeroinitializer
+ br label %for.end47
+
+for.end47: ; preds = %entry
+ %add0.lcssa = phi <2 x double> [ %add0, %entry ]
+ %add1.lcssa = phi <2 x double> [ %add1, %entry ]
+ %add2.lcssa = phi <2 x double> [ %add2, %entry ]
+ %add3.lcssa = phi <2 x double> [ %add3, %entry ]
+ ret i32 0
+}
>From d2165b56b904d658a4b3f0261410214740c815bd Mon Sep 17 00:00:00 2001
From: Han-Kuan Chen <hankuan.chen at sifive.com>
Date: Fri, 20 Dec 2024 02:07:04 -0800
Subject: [PATCH 2/3] [SLP][REVEC] Pre-commit test.
---
.../SLPVectorizer/revec-shufflevector.ll | 111 ++++++++++++++++++
1 file changed, 111 insertions(+)
diff --git a/llvm/test/Transforms/SLPVectorizer/revec-shufflevector.ll b/llvm/test/Transforms/SLPVectorizer/revec-shufflevector.ll
index a2673d81068d8d..35e26d39d2725a 100644
--- a/llvm/test/Transforms/SLPVectorizer/revec-shufflevector.ll
+++ b/llvm/test/Transforms/SLPVectorizer/revec-shufflevector.ll
@@ -121,3 +121,114 @@ entry:
store <4 x i32> %1, ptr %3, align 4
ret void
}
+
+define void @test6(ptr %in0, ptr %in1, ptr %in2) {
+; CHECK-LABEL: @test6(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[GEP1:%.*]] = getelementptr inbounds nuw i8, ptr [[IN0:%.*]], i64 32
+; CHECK-NEXT: [[LOAD2:%.*]] = load <4 x float>, ptr [[GEP1]], align 16
+; CHECK-NEXT: [[TMP0:%.*]] = load <8 x float>, ptr [[IN0]], align 16
+; CHECK-NEXT: [[TMP1:%.*]] = load <32 x i8>, ptr [[IN1:%.*]], align 1
+; CHECK-NEXT: [[TMP2:%.*]] = uitofp <32 x i8> [[TMP1]] to <32 x float>
+; CHECK-NEXT: [[TMP3:%.*]] = shufflevector <8 x float> [[TMP0]], <8 x float> poison, <32 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 poison, i32 poison, i32 poison, i32 poison, i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 poison, i32 poison, i32 poison, i32 poison, i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
+; CHECK-NEXT: [[TMP4:%.*]] = fmul <32 x float> [[TMP3]], [[TMP2]]
+; CHECK-NEXT: store <32 x float> [[TMP4]], ptr [[IN2:%.*]], align 16
+; CHECK-NEXT: [[GEP10:%.*]] = getelementptr inbounds nuw i8, ptr [[IN1]], i64 32
+; CHECK-NEXT: [[LOAD5:%.*]] = load <16 x i8>, ptr [[GEP10]], align 1
+; CHECK-NEXT: [[TMP5:%.*]] = shufflevector <8 x float> [[TMP0]], <8 x float> poison, <4 x i32> <i32 4, i32 5, i32 6, i32 7>
+; CHECK-NEXT: [[GEP11:%.*]] = getelementptr inbounds nuw i8, ptr [[IN2]], i64 128
+; CHECK-NEXT: [[TMP6:%.*]] = uitofp <16 x i8> [[LOAD5]] to <16 x float>
+; CHECK-NEXT: [[TMP7:%.*]] = shufflevector <4 x float> [[LOAD2]], <4 x float> poison, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>
+; CHECK-NEXT: [[TMP8:%.*]] = shufflevector <8 x float> [[TMP0]], <8 x float> poison, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>
+; CHECK-NEXT: [[TMP9:%.*]] = shufflevector <16 x float> [[TMP7]], <16 x float> [[TMP8]], <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 16, i32 17, i32 18, i32 19, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>
+; CHECK-NEXT: [[TMP10:%.*]] = shufflevector <4 x float> [[TMP5]], <4 x float> poison, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>
+; CHECK-NEXT: [[TMP11:%.*]] = shufflevector <16 x float> [[TMP9]], <16 x float> [[TMP10]], <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 16, i32 17, i32 18, i32 19, i32 poison, i32 poison, i32 poison, i32 poison>
+; CHECK-NEXT: [[TMP12:%.*]] = shufflevector <16 x float> [[TMP11]], <16 x float> poison, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 0, i32 1, i32 2, i32 3>
+; CHECK-NEXT: [[TMP13:%.*]] = fmul <16 x float> [[TMP12]], [[TMP6]]
+; CHECK-NEXT: store <16 x float> [[TMP13]], ptr [[GEP11]], align 16
+; CHECK-NEXT: ret void
+;
+entry:
+ %gep0 = getelementptr inbounds i8, ptr %in0, i64 16
+ %gep1 = getelementptr inbounds i8, ptr %in0, i64 32
+ %load0 = load <4 x float>, ptr %in0, align 16
+ %load1 = load <4 x float>, ptr %gep0, align 16
+ %load2 = load <4 x float>, ptr %gep1, align 16
+ %gep2 = getelementptr inbounds i8, ptr %in1, i64 16
+ %load3 = load <16 x i8>, ptr %in1, align 1
+ %load4 = load <16 x i8>, ptr %gep2, align 1
+ %shufflevector0 = shufflevector <16 x i8> %load3, <16 x i8> poison, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
+ %shufflevector1 = shufflevector <16 x i8> %load3, <16 x i8> poison, <8 x i32> <i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
+ %shufflevector2 = shufflevector <16 x i8> %load4, <16 x i8> poison, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
+ %shufflevector3 = shufflevector <16 x i8> %load4, <16 x i8> poison, <8 x i32> <i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
+ %zext0 = zext <8 x i8> %shufflevector0 to <8 x i16>
+ %zext1 = zext <8 x i8> %shufflevector1 to <8 x i16>
+ %zext2 = zext <8 x i8> %shufflevector2 to <8 x i16>
+ %zext3 = zext <8 x i8> %shufflevector3 to <8 x i16>
+ %shufflevector4 = shufflevector <8 x i16> %zext0, <8 x i16> poison, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
+ %shufflevector5 = shufflevector <8 x i16> %zext0, <8 x i16> poison, <4 x i32> <i32 4, i32 5, i32 6, i32 7>
+ %shufflevector6 = shufflevector <8 x i16> %zext1, <8 x i16> poison, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
+ %shufflevector7 = shufflevector <8 x i16> %zext1, <8 x i16> poison, <4 x i32> <i32 4, i32 5, i32 6, i32 7>
+ %shufflevector8 = shufflevector <8 x i16> %zext2, <8 x i16> poison, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
+ %shufflevector9 = shufflevector <8 x i16> %zext2, <8 x i16> poison, <4 x i32> <i32 4, i32 5, i32 6, i32 7>
+ %shufflevector10 = shufflevector <8 x i16> %zext3, <8 x i16> poison, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
+ %shufflevector11 = shufflevector <8 x i16> %zext3, <8 x i16> poison, <4 x i32> <i32 4, i32 5, i32 6, i32 7>
+ %uitofp0 = uitofp nneg <4 x i16> %shufflevector4 to <4 x float>
+ %uitofp1 = uitofp nneg <4 x i16> %shufflevector5 to <4 x float>
+ %uitofp2 = uitofp nneg <4 x i16> %shufflevector6 to <4 x float>
+ %uitofp3 = uitofp nneg <4 x i16> %shufflevector7 to <4 x float>
+ %uitofp4 = uitofp nneg <4 x i16> %shufflevector8 to <4 x float>
+ %uitofp5 = uitofp nneg <4 x i16> %shufflevector9 to <4 x float>
+ %uitofp6 = uitofp nneg <4 x i16> %shufflevector10 to <4 x float>
+ %uitofp7 = uitofp nneg <4 x i16> %shufflevector11 to <4 x float>
+ %fmul0 = fmul <4 x float> %load0, %uitofp0
+ %fmul1 = fmul <4 x float> %load1, %uitofp1
+ %fmul2 = fmul <4 x float> %load2, %uitofp2
+ %fmul3 = fmul <4 x float> %load0, %uitofp3
+ %fmul4 = fmul <4 x float> %load1, %uitofp4
+ %fmul5 = fmul <4 x float> %load2, %uitofp5
+ %fmul6 = fmul <4 x float> %load0, %uitofp6
+ %fmul7 = fmul <4 x float> %load1, %uitofp7
+ %gep3 = getelementptr inbounds i8, ptr %in2, i64 16
+ %gep4 = getelementptr inbounds i8, ptr %in2, i64 32
+ %gep5 = getelementptr inbounds i8, ptr %in2, i64 48
+ %gep6 = getelementptr inbounds i8, ptr %in2, i64 64
+ %gep7 = getelementptr inbounds i8, ptr %in2, i64 80
+ %gep8 = getelementptr inbounds i8, ptr %in2, i64 96
+ %gep9 = getelementptr inbounds i8, ptr %in2, i64 112
+ store <4 x float> %fmul0, ptr %in2, align 16
+ store <4 x float> %fmul1, ptr %gep3, align 16
+ store <4 x float> %fmul2, ptr %gep4, align 16
+ store <4 x float> %fmul3, ptr %gep5, align 16
+ store <4 x float> %fmul4, ptr %gep6, align 16
+ store <4 x float> %fmul5, ptr %gep7, align 16
+ store <4 x float> %fmul6, ptr %gep8, align 16
+ store <4 x float> %fmul7, ptr %gep9, align 16
+ %gep10 = getelementptr inbounds i8, ptr %in1, i64 32
+ %load5 = load <16 x i8>, ptr %gep10, align 1
+ %shufflevector12 = shufflevector <16 x i8> %load5, <16 x i8> poison, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
+ %shufflevector13 = shufflevector <16 x i8> %load5, <16 x i8> poison, <8 x i32> <i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
+ %zext4 = zext <8 x i8> %shufflevector12 to <8 x i16>
+ %zext5 = zext <8 x i8> %shufflevector13 to <8 x i16>
+ %shufflevector14 = shufflevector <8 x i16> %zext4, <8 x i16> poison, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
+ %shufflevector15 = shufflevector <8 x i16> %zext4, <8 x i16> poison, <4 x i32> <i32 4, i32 5, i32 6, i32 7>
+ %shufflevector16 = shufflevector <8 x i16> %zext5, <8 x i16> poison, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
+ %shufflevector17 = shufflevector <8 x i16> %zext5, <8 x i16> poison, <4 x i32> <i32 4, i32 5, i32 6, i32 7>
+ %uitofp8 = uitofp nneg <4 x i16> %shufflevector14 to <4 x float>
+ %uitofp9 = uitofp nneg <4 x i16> %shufflevector15 to <4 x float>
+ %uitofp10 = uitofp nneg <4 x i16> %shufflevector16 to <4 x float>
+ %uitofp11 = uitofp nneg <4 x i16> %shufflevector17 to <4 x float>
+ %fmul8 = fmul <4 x float> %load2, %uitofp8
+ %fmul9 = fmul <4 x float> %load0, %uitofp9
+ %fmul10 = fmul <4 x float> %load1, %uitofp10
+ %fmul11 = fmul <4 x float> %load2, %uitofp11
+ %gep11 = getelementptr inbounds i8, ptr %in2, i64 128
+ %gep12 = getelementptr inbounds i8, ptr %in2, i64 144
+ %gep13 = getelementptr inbounds i8, ptr %in2, i64 160
+ %gep14 = getelementptr inbounds i8, ptr %in2, i64 176
+ store <4 x float> %fmul8, ptr %gep11, align 16
+ store <4 x float> %fmul9, ptr %gep12, align 16
+ store <4 x float> %fmul10, ptr %gep13, align 16
+ store <4 x float> %fmul11, ptr %gep14, align 16
+ ret void
+}
>From cad78f0a2905d1678c29d39b67e1b361ee70a949 Mon Sep 17 00:00:00 2001
From: Han-Kuan Chen <hankuan.chen at sifive.com>
Date: Fri, 24 Jan 2025 00:34:47 -0800
Subject: [PATCH 3/3] [SLP] Fix CommonMask will be transformed into an
incorrect mask if createShuffle is called multiple times.
We have two types of mask in SLP: a scalar mask and a vector mask.
When vectorizing four i32 additions into <4 x i32>, SLP creates a mask
of length 4.
When vectorizing four <2 x i32> additions into <8 x i32>, SLP also
creates a mask of length 4.
We refer to the first case as a scalar mask (because the mask element
represents a scalar, i32), and the second case as a vector mask (because
the mask element represents a vector, <4 x i32>).
At some point, we must convert the scalar mask into a vector mask
(otherwise, calling TTI cost functions or IRBuilderBase functions may
yield incorrect results).
Since both ShuffleCostEstimator and ShuffleInstructionBuilder can modify
the CommonMask, we have decided to perform the mask transformation only
within createShuffle. However, we do not store the transformed result,
as createShuffle may be called multiple times.
---
.../Transforms/Vectorize/SLPVectorizer.cpp | 39 +++++++------------
.../Transforms/SLPVectorizer/RISCV/revec.ll | 19 +++++++++
.../SLPVectorizer/revec-shufflevector.ll | 5 ++-
3 files changed, 38 insertions(+), 25 deletions(-)
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index c98d872fb6467f..8d81fb1427613b 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -9374,8 +9374,15 @@ class BaseShuffleAnalysis {
/// instruction.
template <typename T, typename ShuffleBuilderTy>
static T createShuffle(Value *V1, Value *V2, ArrayRef<int> Mask,
- ShuffleBuilderTy &Builder) {
+ ShuffleBuilderTy &Builder, Type *ScalarTy) {
assert(V1 && "Expected at least one vector value.");
+ unsigned ScalarTyNumElements = getNumElements(ScalarTy);
+ SmallVector<int> NewMask(Mask);
+ if (ScalarTyNumElements != 1) {
+ assert(SLPReVec && "FixedVectorType is not expected.");
+ transformScalarShuffleIndiciesToVector(ScalarTyNumElements, NewMask);
+ Mask = NewMask;
+ }
if (V2)
Builder.resizeToMatch(V1, V2);
int VF = Mask.size();
@@ -9478,7 +9485,6 @@ class BaseShuffleAnalysis {
if (isa<PoisonValue>(V1))
return Builder.createPoison(
cast<VectorType>(V1->getType())->getElementType(), Mask.size());
- SmallVector<int> NewMask(Mask);
bool IsIdentity = peekThroughShuffles(V1, NewMask, /*SinglePermute=*/true);
assert(V1 && "Expected non-null value after looking through shuffles.");
@@ -10643,17 +10649,12 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis {
V2 = getAllOnesValue(*R.DL, getWidenedType(ScalarTy, CommonVF));
}
}
- if (auto *VecTy = dyn_cast<FixedVectorType>(ScalarTy)) {
- assert(SLPReVec && "FixedVectorType is not expected.");
- transformScalarShuffleIndiciesToVector(VecTy->getNumElements(),
- CommonMask);
- }
InVectors.front() =
Constant::getNullValue(getWidenedType(ScalarTy, CommonMask.size()));
if (InVectors.size() == 2)
InVectors.pop_back();
return ExtraCost + BaseShuffleAnalysis::createShuffle<InstructionCost>(
- V1, V2, CommonMask, Builder);
+ V1, V2, CommonMask, Builder, ScalarTy);
}
public:
@@ -14198,8 +14199,8 @@ class BoUpSLP::ShuffleInstructionBuilder final : public BaseShuffleAnalysis {
assert(V1 && "Expected at least one vector value.");
ShuffleIRBuilder ShuffleBuilder(Builder, R.GatherShuffleExtractSeq,
R.CSEBlocks, *R.DL);
- return BaseShuffleAnalysis::createShuffle<Value *>(V1, V2, Mask,
- ShuffleBuilder);
+ return BaseShuffleAnalysis::createShuffle<Value *>(
+ V1, V2, Mask, ShuffleBuilder, ScalarTy);
}
/// Cast value \p V to the vector type with the same number of elements, but
@@ -14518,14 +14519,6 @@ class BoUpSLP::ShuffleInstructionBuilder final : public BaseShuffleAnalysis {
ArrayRef<int> SubVectorsMask, unsigned VF = 0,
function_ref<void(Value *&, SmallVectorImpl<int> &)> Action = {}) {
IsFinalized = true;
- unsigned ScalarTyNumElements = getNumElements(ScalarTy);
- SmallVector<int> NewExtMask(ExtMask);
- if (ScalarTyNumElements != 1) {
- assert(SLPReVec && "FixedVectorType is not expected.");
- transformScalarShuffleIndiciesToVector(ScalarTyNumElements, CommonMask);
- transformScalarShuffleIndiciesToVector(ScalarTyNumElements, NewExtMask);
- ExtMask = NewExtMask;
- }
if (Action) {
Value *Vec = InVectors.front();
if (InVectors.size() == 2) {
@@ -14566,17 +14559,15 @@ class BoUpSLP::ShuffleInstructionBuilder final : public BaseShuffleAnalysis {
return !isKnownNonNegative(
V, SimplifyQuery(*R.DL));
}));
- unsigned InsertionIndex = Idx * ScalarTyNumElements;
+ unsigned InsertionIndex = Idx * getNumElements(ScalarTy);
Vec = createInsertVector(
Builder, Vec, V, InsertionIndex,
std::bind(&ShuffleInstructionBuilder::createShuffle, this, _1, _2,
_3));
if (!CommonMask.empty()) {
- std::iota(
- std::next(CommonMask.begin(), InsertionIndex),
- std::next(CommonMask.begin(),
- (Idx + E->getVectorFactor()) * ScalarTyNumElements),
- InsertionIndex);
+ std::iota(std::next(CommonMask.begin(), Idx),
+ std::next(CommonMask.begin(), Idx + E->getVectorFactor()),
+ Idx);
}
}
return Vec;
diff --git a/llvm/test/Transforms/SLPVectorizer/RISCV/revec.ll b/llvm/test/Transforms/SLPVectorizer/RISCV/revec.ll
index 4267828d42e3d0..dd7a21198ac1f5 100644
--- a/llvm/test/Transforms/SLPVectorizer/RISCV/revec.ll
+++ b/llvm/test/Transforms/SLPVectorizer/RISCV/revec.ll
@@ -233,6 +233,25 @@ define ptr @test4() {
}
define i32 @test5() {
+; CHECK-LABEL: @test5(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[TMP0:%.*]] = call <4 x double> @llvm.vector.insert.v4f64.v2f64(<4 x double> poison, <2 x double> zeroinitializer, i64 0)
+; CHECK-NEXT: [[TMP1:%.*]] = call <4 x double> @llvm.vector.insert.v4f64.v2f64(<4 x double> [[TMP0]], <2 x double> zeroinitializer, i64 2)
+; CHECK-NEXT: [[TMP2:%.*]] = fdiv <4 x double> [[TMP1]], [[TMP1]]
+; CHECK-NEXT: [[TMP3:%.*]] = call <8 x double> @llvm.vector.insert.v8f64.v2f64(<8 x double> poison, <2 x double> zeroinitializer, i64 0)
+; CHECK-NEXT: [[TMP4:%.*]] = call <8 x double> @llvm.vector.insert.v8f64.v2f64(<8 x double> [[TMP3]], <2 x double> zeroinitializer, i64 2)
+; CHECK-NEXT: [[TMP5:%.*]] = call <8 x double> @llvm.vector.insert.v8f64.v2f64(<8 x double> [[TMP4]], <2 x double> zeroinitializer, i64 4)
+; CHECK-NEXT: [[TMP6:%.*]] = call <8 x double> @llvm.vector.insert.v8f64.v2f64(<8 x double> [[TMP5]], <2 x double> zeroinitializer, i64 6)
+; CHECK-NEXT: [[TMP7:%.*]] = call <8 x double> @llvm.vector.insert.v8f64.v2f64(<8 x double> poison, <2 x double> zeroinitializer, i64 2)
+; CHECK-NEXT: [[TMP8:%.*]] = call <8 x double> @llvm.vector.insert.v8f64.v2f64(<8 x double> [[TMP7]], <2 x double> zeroinitializer, i64 6)
+; CHECK-NEXT: [[TMP9:%.*]] = call <8 x double> @llvm.vector.insert.v8f64.v4f64(<8 x double> poison, <4 x double> [[TMP2]], i64 0)
+; CHECK-NEXT: [[TMP10:%.*]] = shufflevector <8 x double> [[TMP9]], <8 x double> [[TMP8]], <8 x i32> <i32 0, i32 1, i32 10, i32 11, i32 2, i32 3, i32 14, i32 15>
+; CHECK-NEXT: [[TMP11:%.*]] = fadd <8 x double> [[TMP6]], [[TMP10]]
+; CHECK-NEXT: br label [[FOR_END47:%.*]]
+; CHECK: for.end47:
+; CHECK-NEXT: [[TMP12:%.*]] = phi <8 x double> [ [[TMP11]], [[ENTRY:%.*]] ]
+; CHECK-NEXT: ret i32 0
+;
entry:
%div0 = fdiv <2 x double> zeroinitializer, zeroinitializer
%div1 = fdiv <2 x double> zeroinitializer, zeroinitializer
diff --git a/llvm/test/Transforms/SLPVectorizer/revec-shufflevector.ll b/llvm/test/Transforms/SLPVectorizer/revec-shufflevector.ll
index 35e26d39d2725a..d6c09bc224a7d1 100644
--- a/llvm/test/Transforms/SLPVectorizer/revec-shufflevector.ll
+++ b/llvm/test/Transforms/SLPVectorizer/revec-shufflevector.ll
@@ -130,7 +130,10 @@ define void @test6(ptr %in0, ptr %in1, ptr %in2) {
; CHECK-NEXT: [[TMP0:%.*]] = load <8 x float>, ptr [[IN0]], align 16
; CHECK-NEXT: [[TMP1:%.*]] = load <32 x i8>, ptr [[IN1:%.*]], align 1
; CHECK-NEXT: [[TMP2:%.*]] = uitofp <32 x i8> [[TMP1]] to <32 x float>
-; CHECK-NEXT: [[TMP3:%.*]] = shufflevector <8 x float> [[TMP0]], <8 x float> poison, <32 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 poison, i32 poison, i32 poison, i32 poison, i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 poison, i32 poison, i32 poison, i32 poison, i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
+; CHECK-NEXT: [[TMP14:%.*]] = shufflevector <8 x float> [[TMP0]], <8 x float> poison, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>
+; CHECK-NEXT: [[TMP15:%.*]] = shufflevector <4 x float> [[LOAD2]], <4 x float> poison, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>
+; CHECK-NEXT: [[TMP16:%.*]] = shufflevector <16 x float> [[TMP14]], <16 x float> [[TMP15]], <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 16, i32 17, i32 18, i32 19, i32 poison, i32 poison, i32 poison, i32 poison>
+; CHECK-NEXT: [[TMP3:%.*]] = shufflevector <16 x float> [[TMP16]], <16 x float> poison, <32 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
; CHECK-NEXT: [[TMP4:%.*]] = fmul <32 x float> [[TMP3]], [[TMP2]]
; CHECK-NEXT: store <32 x float> [[TMP4]], ptr [[IN2:%.*]], align 16
; CHECK-NEXT: [[GEP10:%.*]] = getelementptr inbounds nuw i8, ptr [[IN1]], i64 32
More information about the llvm-commits
mailing list