Skip to content

Commit f99cbd4

Browse files
committed
Remove IsInLoop
1 parent 7c436bf commit f99cbd4

File tree

3 files changed

+19
-19
lines changed

3 files changed

+19
-19
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8286,7 +8286,6 @@ VPRecipeBase *VPRecipeBuilder::tryToCreateWidenRecipe(VPSingleDefRecipe *R,
82868286
? 0
82878287
: getScalingForReduction(RdxDesc.getLoopExitInstr()).value_or(1);
82888288
PhiRecipe = new VPReductionPHIRecipe(Phi, RdxDesc, *StartV,
8289-
CM.isInLoopReduction(Phi),
82908289
UseOrderedReductions, ScaleFactor);
82918290
} else {
82928291
// TODO: Currently fixed-order recurrences are modeled as chains of

llvm/lib/Transforms/Vectorize/VPlan.h

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2180,36 +2180,37 @@ class VPReductionPHIRecipe : public VPHeaderPHIRecipe,
21802180
/// Descriptor for the reduction.
21812181
const RecurrenceDescriptor &RdxDesc;
21822182

2183-
/// The phi is part of an in-loop reduction.
2184-
bool IsInLoop;
2185-
21862183
/// The phi is part of an ordered reduction. Requires IsInLoop to be true.
21872184
bool IsOrdered;
21882185

2189-
/// When expanding the reduction PHI, the plan's VF element count is divided
2190-
/// by this factor to form the reduction phi's VF.
2186+
/// The scaling factor, relative to the VF, that this recipe's output is
2187+
/// divided by.
2188+
/// For outer-loop reductions this is equal to 1.
2189+
/// For in-loop reductions this is equal to 0, to specify that this is equal
2190+
/// to the VF (which may not be known yet). For partial-reductions this is
2191+
/// equal to another scalar value.
21912192
unsigned VFScaleFactor;
21922193

21932194
public:
21942195
/// Create a new VPReductionPHIRecipe for the reduction \p Phi described by \p
21952196
/// RdxDesc.
21962197
VPReductionPHIRecipe(PHINode *Phi, const RecurrenceDescriptor &RdxDesc,
2197-
VPValue &Start, bool IsInLoop = false,
2198-
bool IsOrdered = false, unsigned VFScaleFactor = 1)
2198+
VPValue &Start, bool IsOrdered = false,
2199+
unsigned VFScaleFactor = 1)
21992200
: VPHeaderPHIRecipe(VPDef::VPReductionPHISC, Phi, &Start),
2200-
RdxDesc(RdxDesc), IsInLoop(IsInLoop), IsOrdered(IsOrdered),
2201-
VFScaleFactor(VFScaleFactor) {
2202-
assert((!IsOrdered || IsInLoop) && "IsOrdered requires IsInLoop");
2203-
assert(((!IsInLoop && !IsOrdered) || VFScaleFactor == 0) &&
2201+
RdxDesc(RdxDesc), IsOrdered(IsOrdered), VFScaleFactor(VFScaleFactor) {
2202+
assert((!IsOrdered || isInLoop()) &&
2203+
"IsOrdered requires the reduction to be in-loop");
2204+
assert(((!isInLoop() && !IsOrdered) || isInLoop()) &&
22042205
"Invalid VFScaleFactor");
22052206
}
22062207

22072208
~VPReductionPHIRecipe() override = default;
22082209

22092210
VPReductionPHIRecipe *clone() override {
2210-
auto *R = new VPReductionPHIRecipe(cast<PHINode>(getUnderlyingInstr()),
2211-
RdxDesc, *getOperand(0), IsInLoop,
2212-
IsOrdered, VFScaleFactor);
2211+
auto *R =
2212+
new VPReductionPHIRecipe(cast<PHINode>(getUnderlyingInstr()), RdxDesc,
2213+
*getOperand(0), IsOrdered, VFScaleFactor);
22132214
R->addOperand(getBackedgeValue());
22142215
return R;
22152216
}
@@ -2235,8 +2236,8 @@ class VPReductionPHIRecipe : public VPHeaderPHIRecipe,
22352236
/// Returns true, if the phi is part of an ordered reduction.
22362237
bool isOrdered() const { return IsOrdered; }
22372238

2238-
/// Returns true, if the phi is part of an in-loop reduction.
2239-
bool isInLoop() const { return IsInLoop; }
2239+
/// Returns true if the phi is part of an in-loop reduction.
2240+
bool isInLoop() const { return VFScaleFactor == 0; }
22402241

22412242
bool isPartialReduction() const { return VFScaleFactor > 1; }
22422243

llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3814,7 +3814,7 @@ void VPReductionPHIRecipe::execute(VPTransformState &State) {
38143814
// this value when we vectorize all of the instructions that use the PHI.
38153815
BasicBlock *VectorPH =
38163816
State.CFG.VPBB2IRBB.at(getParent()->getCFGPredecessor(0));
3817-
bool ScalarPHI = State.VF.isScalar() || IsInLoop;
3817+
bool ScalarPHI = State.VF.isScalar() || isInLoop();
38183818
Value *StartV = State.get(StartVPV, ScalarPHI);
38193819
Type *VecTy = StartV->getType();
38203820

@@ -3823,7 +3823,7 @@ void VPReductionPHIRecipe::execute(VPTransformState &State) {
38233823
"recipe must be in the vector loop header");
38243824
auto *Phi = PHINode::Create(VecTy, 2, "vec.phi");
38253825
Phi->insertBefore(HeaderBB->getFirstInsertionPt());
3826-
State.set(this, Phi, IsInLoop);
3826+
State.set(this, Phi, isInLoop());
38273827

38283828
Phi->addIncoming(StartV, VectorPH);
38293829
}

0 commit comments

Comments
 (0)