@@ -1293,8 +1293,7 @@ class BoUpSLP {
1293
1293
using InstrList = SmallVector<Instruction *, 16>;
1294
1294
using ValueSet = SmallPtrSet<Value *, 16>;
1295
1295
using StoreList = SmallVector<StoreInst *, 8>;
1296
- using ExtraValueToDebugLocsMap =
1297
- MapVector<Value *, SmallVector<Instruction *, 2>>;
1296
+ using ExtraValueToDebugLocsMap = SmallDenseSet<Value *, 4>;
1298
1297
using OrdersType = SmallVector<unsigned, 4>;
1299
1298
1300
1299
BoUpSLP(Function *Func, ScalarEvolution *Se, TargetTransformInfo *Tti,
@@ -6322,7 +6321,7 @@ void BoUpSLP::buildExternalUses(
6322
6321
continue;
6323
6322
6324
6323
// Check if the scalar is externally used as an extra arg.
6325
- const auto * ExtI = ExternallyUsedValues.find(Scalar);
6324
+ const auto ExtI = ExternallyUsedValues.find(Scalar);
6326
6325
if (ExtI != ExternallyUsedValues.end()) {
6327
6326
int FoundLane = Entry->findLaneForValue(Scalar);
6328
6327
LLVM_DEBUG(dbgs() << "SLP: Need to extract: Extra arg from lane "
@@ -18820,7 +18819,7 @@ class HorizontalReduction {
18820
18819
// List of the values that were reduced in other trees as part of gather
18821
18820
// nodes and thus requiring extract if fully vectorized in other trees.
18822
18821
SmallPtrSet<Value *, 4> RequiredExtract;
18823
- Value * VectorizedTree = nullptr;
18822
+ WeakTrackingVH VectorizedTree = nullptr;
18824
18823
bool CheckForReusedReductionOps = false;
18825
18824
// Try to vectorize elements based on their type.
18826
18825
SmallVector<InstructionsState> States;
@@ -18916,6 +18915,7 @@ class HorizontalReduction {
18916
18915
bool SameScaleFactor = false;
18917
18916
bool OptReusedScalars = IsSupportedHorRdxIdentityOp &&
18918
18917
SameValuesCounter.size() != Candidates.size();
18918
+ BoUpSLP::ExtraValueToDebugLocsMap ExternallyUsedValues;
18919
18919
if (OptReusedScalars) {
18920
18920
SameScaleFactor =
18921
18921
(RdxKind == RecurKind::Add || RdxKind == RecurKind::FAdd ||
@@ -18936,6 +18936,7 @@ class HorizontalReduction {
18936
18936
emitScaleForReusedOps(Candidates.front(), Builder, Cnt);
18937
18937
VectorizedTree = GetNewVectorizedTree(VectorizedTree, RedVal);
18938
18938
VectorizedVals.try_emplace(OrigV, Cnt);
18939
+ ExternallyUsedValues.insert(OrigV);
18939
18940
continue;
18940
18941
}
18941
18942
}
@@ -19015,17 +19016,18 @@ class HorizontalReduction {
19015
19016
V.reorderBottomToTop(/*IgnoreReorder=*/true);
19016
19017
// Keep extracted other reduction values, if they are used in the
19017
19018
// vectorization trees.
19018
- BoUpSLP::ExtraValueToDebugLocsMap LocalExternallyUsedValues;
19019
+ BoUpSLP::ExtraValueToDebugLocsMap LocalExternallyUsedValues(
19020
+ ExternallyUsedValues);
19019
19021
// The reduction root is used as the insertion point for new
19020
19022
// instructions, so set it as externally used to prevent it from being
19021
19023
// deleted.
19022
- LocalExternallyUsedValues[ ReductionRoot] ;
19024
+ LocalExternallyUsedValues.insert( ReductionRoot) ;
19023
19025
for (unsigned Cnt = 0, Sz = ReducedVals.size(); Cnt < Sz; ++Cnt) {
19024
19026
if (Cnt == I || (ShuffledExtracts && Cnt == I - 1))
19025
19027
continue;
19026
19028
for (Value *V : ReducedVals[Cnt])
19027
19029
if (isa<Instruction>(V))
19028
- LocalExternallyUsedValues[ TrackedVals[V]] ;
19030
+ LocalExternallyUsedValues.insert( TrackedVals[V]) ;
19029
19031
}
19030
19032
if (!IsSupportedHorRdxIdentityOp) {
19031
19033
// Number of uses of the candidates in the vector of values.
@@ -19054,21 +19056,21 @@ class HorizontalReduction {
19054
19056
// Check if the scalar was vectorized as part of the vectorization
19055
19057
// tree but not the top node.
19056
19058
if (!VLScalars.contains(RdxVal) && V.isVectorized(RdxVal)) {
19057
- LocalExternallyUsedValues[ RdxVal] ;
19059
+ LocalExternallyUsedValues.insert( RdxVal) ;
19058
19060
continue;
19059
19061
}
19060
19062
Value *OrigV = TrackedToOrig.at(RdxVal);
19061
19063
unsigned NumOps =
19062
19064
VectorizedVals.lookup(OrigV) + At(SameValuesCounter, OrigV);
19063
19065
if (NumOps != ReducedValsToOps.at(OrigV).size())
19064
- LocalExternallyUsedValues[ RdxVal] ;
19066
+ LocalExternallyUsedValues.insert( RdxVal) ;
19065
19067
}
19066
19068
// Do not need the list of reused scalars in regular mode anymore.
19067
19069
if (!IsSupportedHorRdxIdentityOp)
19068
19070
SameValuesCounter.clear();
19069
19071
for (Value *RdxVal : VL)
19070
19072
if (RequiredExtract.contains(RdxVal))
19071
- LocalExternallyUsedValues[ RdxVal] ;
19073
+ LocalExternallyUsedValues.insert( RdxVal) ;
19072
19074
V.buildExternalUses(LocalExternallyUsedValues);
19073
19075
19074
19076
V.computeMinimumValueSizes();
0 commit comments