Skip to content

Commit b6bcfde

Browse files
committed
[VPlan] Get opcode & type from recipe in adjustRecipesForReduction (NFC)
Replace direct access to underlying IR instructions with VPlan-level equivalents, i.e. VPTypeAnalysis and pattern matching on the recipe. Removes a few uses of accessing underlying IR.
1 parent 71763a5 commit b6bcfde

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8621,6 +8621,7 @@ VPlanPtr LoopVectorizationPlanner::tryToBuildVPlan(VFRange &Range) {
86218621
void LoopVectorizationPlanner::adjustRecipesForReductions(
86228622
VPlanPtr &Plan, VPRecipeBuilder &RecipeBuilder, ElementCount MinVF) {
86238623
using namespace VPlanPatternMatch;
8624+
VPTypeAnalysis TypeInfo(*Plan);
86248625
VPRegionBlock *VectorLoopRegion = Plan->getVectorLoopRegion();
86258626
VPBasicBlock *Header = VectorLoopRegion->getEntryBasicBlock();
86268627
VPBasicBlock *MiddleVPBB = Plan->getMiddleBlock();
@@ -8705,8 +8706,8 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
87058706
LinkVPBB->insert(FMulRecipe, CurrentLink->getIterator());
87068707
VecOp = FMulRecipe;
87078708
} else if (PhiR->isInLoop() && Kind == RecurKind::AddChainWithSubs &&
8708-
CurrentLinkI->getOpcode() == Instruction::Sub) {
8709-
Type *PhiTy = PhiR->getUnderlyingValue()->getType();
8709+
match(CurrentLink, m_Sub(m_VPValue(), m_VPValue()))) {
8710+
Type *PhiTy = TypeInfo.inferScalarType(PhiR);
87108711
auto *Zero = Plan->getConstantInt(PhiTy, 0);
87118712
VPWidenRecipe *Sub = new VPWidenRecipe(
87128713
Instruction::Sub, {Zero, CurrentLink->getOperand(1)}, {},
@@ -8782,7 +8783,7 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
87828783

87838784
const RecurrenceDescriptor &RdxDesc = Legal->getRecurrenceDescriptor(
87848785
cast<PHINode>(PhiR->getUnderlyingInstr()));
8785-
Type *PhiTy = PhiR->getUnderlyingValue()->getType();
8786+
Type *PhiTy = TypeInfo.inferScalarType(PhiR);
87868787
// If tail is folded by masking, introduce selects between the phi
87878788
// and the users outside the vector region of each reduction, at the
87888789
// beginning of the dedicated latch block.

0 commit comments

Comments
 (0)