Skip to content

Commit ead713a

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 0d7c8c0 commit ead713a

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
@@ -8821,7 +8821,8 @@ void VPRecipeBuilder::collectScaledReductions(VFRange &Range) {
88218821
PartialReductionChain Chain = Pair.first;
88228822
if (ExtendIsOnlyUsedByPartialReductions(Chain.ExtendA) &&
88238823
ExtendIsOnlyUsedByPartialReductions(Chain.ExtendB))
8824-
ScaledReductionExitInstrs.insert(std::make_pair(Chain.Reduction, Pair));
8824+
ScaledReductionExitInstrs.insert(
8825+
std::make_pair(Chain.Reduction, Pair.second));
88258826
}
88268827
}
88278828

@@ -8913,9 +8914,9 @@ VPRecipeBuilder::tryToCreateWidenRecipe(Instruction *Instr,
89138914
Phi->getIncomingValueForBlock(OrigLoop->getLoopPreheader()));
89148915

89158916
// If the PHI is used by a partial reduction, set the scale factor.
8916-
std::optional<std::pair<PartialReductionChain, unsigned>> Pair =
8917+
std::optional<unsigned> Scale =
89178918
getScaledReductionForInstr(RdxDesc.getLoopExitInstr());
8918-
unsigned ScaleFactor = Pair ? Pair->second : 1;
8919+
unsigned ScaleFactor = Scale ? *Scale : 1;
89198920
PhiRecipe = new VPReductionPHIRecipe(
89208921
Phi, RdxDesc, *StartV, CM.isInLoopReduction(Phi),
89218922
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)