Skip to content

Commit cb4b75d

Browse files
committed
!fixup address comments, thanks
1 parent 0ab71f6 commit cb4b75d

File tree

3 files changed

+15
-19
lines changed

3 files changed

+15
-19
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9171,6 +9171,7 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
91719171
if (CM.blockNeedsPredicationForAnyReason(CurrentLinkI->getParent()))
91729172
CondOp = RecipeBuilder.getBlockInMask(CurrentLink->getParent());
91739173

9174+
// TODO: Retrieve FMFs from recipes directly.
91749175
RecurrenceDescriptor RdxDesc = Legal->getRecurrenceDescriptor(
91759176
cast<PHINode>(PhiR->getUnderlyingInstr()));
91769177
// Non-FP RdxDescs will have all fast math flags set, so clear them.
@@ -9252,24 +9253,23 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
92529253
VPInstruction *FinalReductionResult;
92539254
VPBuilder::InsertPointGuard Guard(Builder);
92549255
Builder.setInsertPoint(MiddleVPBB, IP);
9255-
if (RecurrenceDescriptor::isFindIVRecurrenceKind(
9256-
RdxDesc.getRecurrenceKind())) {
9256+
RecurKind RecurrenceKind = PhiR->getRecurrenceKind();
9257+
if (RecurrenceDescriptor::isFindIVRecurrenceKind(RecurrenceKind)) {
92579258
VPValue *Start = PhiR->getStartValue();
92589259
VPValue *Sentinel = Plan->getOrAddLiveIn(RdxDesc.getSentinelValue());
92599260
FinalReductionResult =
92609261
Builder.createNaryOp(VPInstruction::ComputeFindIVResult,
92619262
{PhiR, Start, Sentinel, NewExitingVPV}, ExitDL);
9262-
} else if (RecurrenceDescriptor::isAnyOfRecurrenceKind(
9263-
RdxDesc.getRecurrenceKind())) {
9263+
} else if (RecurrenceDescriptor::isAnyOfRecurrenceKind(RecurrenceKind)) {
92649264
VPValue *Start = PhiR->getStartValue();
92659265
FinalReductionResult =
92669266
Builder.createNaryOp(VPInstruction::ComputeAnyOfResult,
92679267
{PhiR, Start, NewExitingVPV}, ExitDL);
92689268
} else {
9269-
VPIRFlags Flags = RecurrenceDescriptor::isFloatingPointRecurrenceKind(
9270-
RdxDesc.getRecurrenceKind())
9271-
? VPIRFlags(RdxDesc.getFastMathFlags())
9272-
: VPIRFlags();
9269+
VPIRFlags Flags =
9270+
RecurrenceDescriptor::isFloatingPointRecurrenceKind(RecurrenceKind)
9271+
? VPIRFlags(RdxDesc.getFastMathFlags())
9272+
: VPIRFlags();
92739273
FinalReductionResult =
92749274
Builder.createNaryOp(VPInstruction::ComputeReductionResult,
92759275
{PhiR, NewExitingVPV}, Flags, ExitDL);
@@ -9278,11 +9278,9 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
92789278
// then extend the loop exit value to enable InstCombine to evaluate the
92799279
// entire expression in the smaller type.
92809280
if (MinVF.isVector() && PhiTy != RdxDesc.getRecurrenceType() &&
9281-
!RecurrenceDescriptor::isAnyOfRecurrenceKind(
9282-
RdxDesc.getRecurrenceKind())) {
9281+
!RecurrenceDescriptor::isAnyOfRecurrenceKind(RecurrenceKind)) {
92839282
assert(!PhiR->isInLoop() && "Unexpected truncated inloop reduction!");
9284-
assert(!RecurrenceDescriptor::isMinMaxRecurrenceKind(
9285-
RdxDesc.getRecurrenceKind()) &&
9283+
assert(!RecurrenceDescriptor::isMinMaxRecurrenceKind(RecurrenceKind) &&
92869284
"Unexpected truncated min-max recurrence!");
92879285
Type *RdxTy = RdxDesc.getRecurrenceType();
92889286
auto *Trunc =
@@ -9318,8 +9316,7 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
93189316
// with a boolean reduction phi node to check if the condition is true in
93199317
// any iteration. The final value is selected by the final
93209318
// ComputeReductionResult.
9321-
if (RecurrenceDescriptor::isAnyOfRecurrenceKind(
9322-
RdxDesc.getRecurrenceKind())) {
9319+
if (RecurrenceDescriptor::isAnyOfRecurrenceKind(RecurrenceKind)) {
93239320
auto *Select = cast<VPRecipeBase>(*find_if(PhiR->users(), [](VPUser *U) {
93249321
return isa<VPWidenSelectRecipe>(U) ||
93259322
(isa<VPReplicateRecipe>(U) &&

llvm/lib/Transforms/Vectorize/VPlan.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2191,7 +2191,7 @@ struct VPFirstOrderRecurrencePHIRecipe : public VPHeaderPHIRecipe {
21912191
/// operand.
21922192
class VPReductionPHIRecipe : public VPHeaderPHIRecipe,
21932193
public VPUnrollPartAccessor<2> {
2194-
/// Descriptor for the reduction.
2194+
/// The recurrence kind of the reduction.
21952195
const RecurKind Kind;
21962196

21972197
/// The phi is part of an in-loop reduction.
@@ -2205,8 +2205,7 @@ class VPReductionPHIRecipe : public VPHeaderPHIRecipe,
22052205
unsigned VFScaleFactor = 1;
22062206

22072207
public:
2208-
/// Create a new VPReductionPHIRecipe for the reduction \p Phi described by \p
2209-
/// Kind.
2208+
/// Create a new VPReductionPHIRecipe for the reduction \p Phi.
22102209
VPReductionPHIRecipe(PHINode *Phi, RecurKind Kind, VPValue &Start,
22112210
bool IsInLoop = false, bool IsOrdered = false,
22122211
unsigned VFScaleFactor = 1)
@@ -2218,7 +2217,6 @@ class VPReductionPHIRecipe : public VPHeaderPHIRecipe,
22182217
~VPReductionPHIRecipe() override = default;
22192218

22202219
VPReductionPHIRecipe *clone() override {
2221-
22222220
auto *R = new VPReductionPHIRecipe(
22232221
dyn_cast_or_null<PHINode>(getUnderlyingValue()), getRecurrenceKind(),
22242222
*getOperand(0), IsInLoop, IsOrdered, VFScaleFactor);
@@ -2240,6 +2238,7 @@ class VPReductionPHIRecipe : public VPHeaderPHIRecipe,
22402238
VPSlotTracker &SlotTracker) const override;
22412239
#endif
22422240

2241+
/// Returns the recurrence kind of the reduction.
22432242
RecurKind getRecurrenceKind() const { return Kind; }
22442243

22452244
/// Returns true, if the phi is part of an ordered reduction.

llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -751,7 +751,7 @@ Value *VPInstruction::generate(VPTransformState &State) {
751751
// and will be removed by breaking up the recipe further.
752752
auto *PhiR = cast<VPReductionPHIRecipe>(getOperand(0));
753753
// Get its reduction variable descriptor.
754-
[[maybe_unused]] RecurKind RK = PhiR->getRecurrenceKind();
754+
RecurKind RK = PhiR->getRecurrenceKind();
755755
assert(RecurrenceDescriptor::isFindIVRecurrenceKind(RK) &&
756756
"Unexpected reduction kind");
757757
assert(!PhiR->isInLoop() &&

0 commit comments

Comments
 (0)