Skip to content

Commit 205e6f2

Browse files
committed
Address review comments
1 parent e94fb88 commit 205e6f2

File tree

2 files changed

+10
-14
lines changed

2 files changed

+10
-14
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8711,8 +8711,7 @@ void VPRecipeBuilder::collectScaledReductions(VFRange &Range) {
87118711
PartialReductionChain Chain = Pair.first;
87128712
if (ExtendIsOnlyUsedByPartialReductions(Chain.ExtendA) &&
87138713
ExtendIsOnlyUsedByPartialReductions(Chain.ExtendB))
8714-
ScaledReductionExitInstrs.insert(
8715-
std::make_pair(Chain.Reduction, Pair.second));
8714+
ScaledReductionMap.insert(std::make_pair(Chain.Reduction, Pair.second));
87168715
}
87178716
}
87188717

@@ -8805,8 +8804,8 @@ VPRecipeBuilder::tryToCreateWidenRecipe(Instruction *Instr,
88058804

88068805
// If the PHI is used by a partial reduction, set the scale factor.
88078806
std::optional<unsigned> Scale =
8808-
getScaledReductionForInstr(RdxDesc.getLoopExitInstr());
8809-
unsigned ScaleFactor = Scale ? *Scale : 1;
8807+
getScalingForReduction(RdxDesc.getLoopExitInstr());
8808+
unsigned ScaleFactor = Scale.value_or(1);
88108809
PhiRecipe = new VPReductionPHIRecipe(
88118810
Phi, RdxDesc, *StartV, CM.isInLoopReduction(Phi),
88128811
CM.useOrderedReductions(RdxDesc), ScaleFactor);
@@ -8841,7 +8840,7 @@ VPRecipeBuilder::tryToCreateWidenRecipe(Instruction *Instr,
88418840
if (isa<LoadInst>(Instr) || isa<StoreInst>(Instr))
88428841
return tryToWidenMemory(Instr, Operands, Range);
88438842

8844-
if (getScaledReductionForInstr(Instr))
8843+
if (getScalingForReduction(Instr))
88458844
return tryToCreatePartialReduction(Instr, Operands);
88468845

88478846
if (!shouldWiden(Instr, Range))

llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,8 @@ class VPRecipeBuilder {
8686
/// created.
8787
SmallVector<VPHeaderPHIRecipe *, 4> PhisToFix;
8888

89-
/// The set of reduction exit instructions that will be scaled to
90-
/// a smaller VF via partial reductions, paired with the scaling factor.
91-
DenseMap<const Instruction *, unsigned> ScaledReductionExitInstrs;
89+
/// A mapping of partial reduction exit instructions to their scaling factor.
90+
DenseMap<const Instruction *, unsigned> ScaledReductionMap;
9291

9392
/// Check if \p I can be widened at the start of \p Range and possibly
9493
/// decrease the range such that the returned value holds for the entire \p
@@ -156,12 +155,10 @@ class VPRecipeBuilder {
156155
: Plan(Plan), OrigLoop(OrigLoop), TLI(TLI), TTI(TTI), Legal(Legal),
157156
CM(CM), PSE(PSE), Builder(Builder) {}
158157

159-
std::optional<unsigned>
160-
getScaledReductionForInstr(const Instruction *ExitInst) {
161-
auto It = ScaledReductionExitInstrs.find(ExitInst);
162-
return It == ScaledReductionExitInstrs.end()
163-
? std::nullopt
164-
: std::make_optional(It->second);
158+
std::optional<unsigned> getScalingForReduction(const Instruction *ExitInst) {
159+
auto It = ScaledReductionMap.find(ExitInst);
160+
return It == ScaledReductionMap.end() ? std::nullopt
161+
: std::make_optional(It->second);
165162
}
166163

167164
/// Find all possible partial reductions in the loop and track all of those

0 commit comments

Comments
 (0)