Skip to content

Commit 0ab71f6

Browse files
committed
Merge remote-tracking branch 'origin/main' into vplan-replace-rdxdesc-with-recurkind
2 parents 4c2e494 + c5fff13 commit 0ab71f6

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

llvm/include/llvm/Transforms/Vectorize/LoopVectorizationLegality.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -301,9 +301,12 @@ class LoopVectorizationLegality {
301301
/// Returns the reduction variables found in the loop.
302302
const ReductionList &getReductionVars() const { return Reductions; }
303303

304-
RecurrenceDescriptor getRecurrenceDescriptor(PHINode *PN) const {
305-
assert(Reductions.contains(PN) && "no recurrence descriptor for phi");
306-
return Reductions.lookup(PN);
304+
/// Returns the recurrence descriptor associated with a given phi node \p PN,
305+
/// expecting one to exist.
306+
const RecurrenceDescriptor &getRecurrenceDescriptor(PHINode *PN) const {
307+
assert(isReductionVariable(PN) &&
308+
"only reductions have recurrence descriptors");
309+
return Reductions.find(PN)->second;
307310
}
308311

309312
/// Returns the induction variables found in the loop.

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4676,7 +4676,7 @@ void LoopVectorizationCostModel::collectElementTypesForWidening() {
46764676
if (!Legal->isReductionVariable(PN))
46774677
continue;
46784678
const RecurrenceDescriptor &RdxDesc =
4679-
Legal->getReductionVars().find(PN)->second;
4679+
Legal->getRecurrenceDescriptor(PN);
46804680
if (PreferInLoopReductions || useOrderedReductions(RdxDesc) ||
46814681
TTI.preferInLoopReduction(RdxDesc.getRecurrenceKind(),
46824682
RdxDesc.getRecurrenceType()))
@@ -5476,7 +5476,7 @@ LoopVectorizationCostModel::getReductionPatternCost(Instruction *I,
54765476
ReductionPhi = InLoopReductionImmediateChains.at(ReductionPhi);
54775477

54785478
const RecurrenceDescriptor &RdxDesc =
5479-
Legal->getReductionVars().find(cast<PHINode>(ReductionPhi))->second;
5479+
Legal->getRecurrenceDescriptor(cast<PHINode>(ReductionPhi));
54805480

54815481
InstructionCost BaseCost;
54825482
RecurKind RK = RdxDesc.getRecurrenceKind();
@@ -8297,8 +8297,7 @@ VPRecipeBase *VPRecipeBuilder::tryToCreateWidenRecipe(VPSingleDefRecipe *R,
82978297
"can only widen reductions and fixed-order recurrences here");
82988298
VPValue *StartV = Operands[0];
82998299
if (Legal->isReductionVariable(Phi)) {
8300-
const RecurrenceDescriptor &RdxDesc =
8301-
Legal->getReductionVars().find(Phi)->second;
8300+
const RecurrenceDescriptor &RdxDesc = Legal->getRecurrenceDescriptor(Phi);
83028301
assert(RdxDesc.getRecurrenceStartValue() ==
83038302
Phi->getIncomingValueForBlock(OrigLoop->getLoopPreheader()));
83048303

0 commit comments

Comments
 (0)