Skip to content

Commit b19facf

Browse files
committed
[LV] Check isPredInst instead of isScalarWithPred in uniform analysis.
Any instruction marked as uniform will result in a uniform VPReplicateRecipe. If it requires predication, it will be placed in a replicate region, even if isScalarWithPredication returns false. Check isPredicatedInst instead of isScalarWithPredication to avoid generating uniform VPReplicateRecipes placed inside a replicate region. This fixes an assertion when using scalable VFs. Fixes #80416. Fixes #94328.
1 parent 967eba0 commit b19facf

File tree

3 files changed

+398
-5
lines changed

3 files changed

+398
-5
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3907,7 +3907,7 @@ void LoopVectorizationCostModel::collectLoopUniforms(ElementCount VF) {
39073907
SetVector<Instruction *> Worklist;
39083908

39093909
// Add uniform instructions demanding lane 0 to the worklist. Instructions
3910-
// that are scalar with predication must not be considered uniform after
3910+
// that are require predication must not be considered uniform after
39113911
// vectorization, because that would create an erroneous replicating region
39123912
// where only a single instance out of VF should be formed.
39133913
// TODO: optimize such seldom cases if found important, see PR40816.
@@ -3917,9 +3917,10 @@ void LoopVectorizationCostModel::collectLoopUniforms(ElementCount VF) {
39173917
<< *I << "\n");
39183918
return;
39193919
}
3920-
if (isScalarWithPredication(I, VF)) {
3921-
LLVM_DEBUG(dbgs() << "LV: Found not uniform being ScalarWithPredication: "
3922-
<< *I << "\n");
3920+
if (isPredicatedInst(I)) {
3921+
LLVM_DEBUG(
3922+
dbgs() << "LV: Found not uniform due to requiring predication: " << *I
3923+
<< "\n");
39233924
return;
39243925
}
39253926
LLVM_DEBUG(dbgs() << "LV: Found uniform instruction: " << *I << "\n");
@@ -9482,6 +9483,7 @@ void VPInterleaveRecipe::execute(VPTransformState &State) {
94829483
void VPReplicateRecipe::execute(VPTransformState &State) {
94839484
Instruction *UI = getUnderlyingInstr();
94849485
if (State.Instance) { // Generate a single instance.
9486+
assert((State.VF.isScalar() || !isUniform()) && "uniform recipe shouldn't be predicated");
94859487
assert(!State.VF.isScalable() && "Can't scalarize a scalable vector");
94869488
State.ILV->scalarizeInstruction(UI, this, *State.Instance, State);
94879489
// Insert scalar instance packing it into a vector.

0 commit comments

Comments
 (0)