Skip to content

Commit 26fa3af

Browse files
committed
!fixup add assertions, use dyn_cast_if_present
1 parent 4435fa1 commit 26fa3af

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -329,9 +329,12 @@ VPPartialReductionRecipe::computeCost(ElementCount VF,
329329
// recipe.
330330
auto HandleWiden = [&](VPWidenRecipe *Widen) {
331331
if (match(Widen, m_Sub(m_ZeroInt(), m_VPValue(Op)))) {
332-
Widen = dyn_cast<VPWidenRecipe>(Op->getDefiningRecipe());
333-
if (!Widen)
332+
Widen = dyn_cast<VPWidenRecipe>(Op);
333+
if (!Widen) {
334+
assert(Op->isLiveIn() &&
335+
"Operand must either be a VPWidenRecipe or a live-in");
334336
return;
337+
}
335338
}
336339
Opcode = Widen->getOpcode();
337340
VPRecipeBase *ExtAR = Widen->getOperand(0)->getDefiningRecipe();
@@ -362,9 +365,10 @@ VPPartialReductionRecipe::computeCost(ElementCount VF,
362365
ExtAType = GetExtendKind(RedPhiOp1R);
363366
} else if (auto Widen = dyn_cast_if_present<VPWidenRecipe>(RedPhiOp1R))
364367
HandleWiden(Widen);
365-
} else if (auto Widen = dyn_cast<VPWidenRecipe>(OpR)) {
368+
} else if (auto Widen = dyn_cast_if_present<VPWidenRecipe>(OpR)) {
366369
HandleWiden(Widen);
367-
} else if (auto Reduction = dyn_cast<VPPartialReductionRecipe>(OpR)) {
370+
} else if (auto Reduction =
371+
dyn_cast_if_present<VPPartialReductionRecipe>(OpR)) {
368372
return Reduction->computeCost(VF, Ctx);
369373
}
370374
auto *PhiType = Ctx.Types.inferScalarType(getOperand(1));

0 commit comments

Comments
 (0)