Skip to content

Commit 2ccec61

Browse files
committed
Fix asserts after rebase
1 parent 2275840 commit 2ccec61

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4280,7 +4280,24 @@ VectorizationFactor LoopVectorizationPlanner::selectVectorizationFactor() {
42804280
switch (VPI->getOpcode()) {
42814281
// Selects are not modelled in the legacy cost model if they are
42824282
// inserted for reductions.
4283-
case Instruction::Select:
4283+
case Instruction::Select: {
4284+
VPValue *V =
4285+
R.getNumDefinedValues() == 1 ? R.getVPSingleValue() : nullptr;
4286+
if (V && V->getNumUsers() == 1) {
4287+
if (auto *UR = dyn_cast<VPWidenRecipe>(*V->user_begin())) {
4288+
switch (UR->getOpcode()) {
4289+
case Instruction::UDiv:
4290+
case Instruction::SDiv:
4291+
case Instruction::URem:
4292+
case Instruction::SRem:
4293+
continue;
4294+
default:
4295+
break;
4296+
}
4297+
}
4298+
}
4299+
[[fallthrough]];
4300+
}
42844301
case VPInstruction::ActiveLaneMask:
42854302
case VPInstruction::ExplicitVectorLength:
42864303
C += VPI->cost(VF, CostCtx);

0 commit comments

Comments
 (0)