Skip to content

Commit e94fb88

Browse files
committed
[LoopVectorize][NFC] Simplify ScaledReductionExitInstrs map
For the following variable DenseMap<const Instruction *, std::pair<PartialReductionChain, unsigned>> ScaledReductionExitInstrs; we never actually need the PartialReductionChain when using the map. I've cleaned this up so that this now becomes DenseMap<const Instruction *, unsigned> ScaledReductionExitInstrs;
1 parent 5139c90 commit e94fb88

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

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

@@ -8803,9 +8804,9 @@ VPRecipeBuilder::tryToCreateWidenRecipe(Instruction *Instr,
88038804
Phi->getIncomingValueForBlock(OrigLoop->getLoopPreheader()));
88048805

88058806
// If the PHI is used by a partial reduction, set the scale factor.
8806-
std::optional<std::pair<PartialReductionChain, unsigned>> Pair =
8807+
std::optional<unsigned> Scale =
88078808
getScaledReductionForInstr(RdxDesc.getLoopExitInstr());
8808-
unsigned ScaleFactor = Pair ? Pair->second : 1;
8809+
unsigned ScaleFactor = Scale ? *Scale : 1;
88098810
PhiRecipe = new VPReductionPHIRecipe(
88108811
Phi, RdxDesc, *StartV, CM.isInLoopReduction(Phi),
88118812
CM.useOrderedReductions(RdxDesc), ScaleFactor);

llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,7 @@ class VPRecipeBuilder {
8888

8989
/// The set of reduction exit instructions that will be scaled to
9090
/// a smaller VF via partial reductions, paired with the scaling factor.
91-
DenseMap<const Instruction *, std::pair<PartialReductionChain, unsigned>>
92-
ScaledReductionExitInstrs;
91+
DenseMap<const Instruction *, unsigned> ScaledReductionExitInstrs;
9392

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

160-
std::optional<std::pair<PartialReductionChain, unsigned>>
159+
std::optional<unsigned>
161160
getScaledReductionForInstr(const Instruction *ExitInst) {
162161
auto It = ScaledReductionExitInstrs.find(ExitInst);
163162
return It == ScaledReductionExitInstrs.end()

0 commit comments

Comments
 (0)