@@ -304,7 +304,6 @@ class BoUpSLP {
304
304
typedef SmallVector<Instruction *, 16 > InstrList;
305
305
typedef SmallPtrSet<Value *, 16 > ValueSet;
306
306
typedef SmallVector<StoreInst *, 8 > StoreList;
307
- typedef MapVector<Value *, SmallVector<DebugLoc, 4 >> ExtraValueToDebugLocsMap;
308
307
309
308
BoUpSLP (Function *Func, ScalarEvolution *Se, TargetTransformInfo *Tti,
310
309
TargetLibraryInfo *TLi, AliasAnalysis *Aa, LoopInfo *Li,
@@ -334,7 +333,7 @@ class BoUpSLP {
334
333
// / Vectorize the tree but with the list of externally used values \p
335
334
// / ExternallyUsedValues. Values in this MapVector can be replaced but the
336
335
// / generated extractvalue instructions.
337
- Value *vectorizeTree (ExtraValueToDebugLocsMap &ExternallyUsedValues);
336
+ Value *vectorizeTree (MapVector<Value *, DebugLoc> &ExternallyUsedValues);
338
337
339
338
// / \returns the cost incurred by unwanted spills and fills, caused by
340
339
// / holding live values over call sites.
@@ -353,7 +352,7 @@ class BoUpSLP {
353
352
// / into account (anf updating it, if required) list of externally used
354
353
// / values stored in \p ExternallyUsedValues.
355
354
void buildTree (ArrayRef<Value *> Roots,
356
- ExtraValueToDebugLocsMap &ExternallyUsedValues,
355
+ MapVector<Value *, DebugLoc> &ExternallyUsedValues,
357
356
ArrayRef<Value *> UserIgnoreLst = None);
358
357
359
358
// / Clear the internal data structures that are created by 'buildTree'.
@@ -954,11 +953,11 @@ class BoUpSLP {
954
953
955
954
void BoUpSLP::buildTree (ArrayRef<Value *> Roots,
956
955
ArrayRef<Value *> UserIgnoreLst) {
957
- ExtraValueToDebugLocsMap ExternallyUsedValues;
956
+ MapVector<Value *, DebugLoc> ExternallyUsedValues;
958
957
buildTree (Roots, ExternallyUsedValues, UserIgnoreLst);
959
958
}
960
959
void BoUpSLP::buildTree (ArrayRef<Value *> Roots,
961
- ExtraValueToDebugLocsMap &ExternallyUsedValues,
960
+ MapVector<Value *, DebugLoc> &ExternallyUsedValues,
962
961
ArrayRef<Value *> UserIgnoreLst) {
963
962
deleteTree ();
964
963
UserIgnoreList = UserIgnoreLst;
@@ -2802,12 +2801,12 @@ Value *BoUpSLP::vectorizeTree(ArrayRef<Value *> VL, TreeEntry *E) {
2802
2801
}
2803
2802
2804
2803
Value *BoUpSLP::vectorizeTree () {
2805
- ExtraValueToDebugLocsMap ExternallyUsedValues;
2804
+ MapVector<Value *, DebugLoc> ExternallyUsedValues;
2806
2805
return vectorizeTree (ExternallyUsedValues);
2807
2806
}
2808
2807
2809
2808
Value *
2810
- BoUpSLP::vectorizeTree (ExtraValueToDebugLocsMap &ExternallyUsedValues) {
2809
+ BoUpSLP::vectorizeTree (MapVector<Value *, DebugLoc> &ExternallyUsedValues) {
2811
2810
2812
2811
// All blocks must be scheduled before any instructions are inserted.
2813
2812
for (auto &BSIter : BlocksSchedules) {
@@ -2869,6 +2868,7 @@ BoUpSLP::vectorizeTree(ExtraValueToDebugLocsMap &ExternallyUsedValues) {
2869
2868
assert (ExternallyUsedValues.count (Scalar) &&
2870
2869
" Scalar with nullptr as an external user must be registered in "
2871
2870
" ExternallyUsedValues map" );
2871
+ DebugLoc DL = ExternallyUsedValues[Scalar];
2872
2872
if (auto *VecI = dyn_cast<Instruction>(Vec)) {
2873
2873
Builder.SetInsertPoint (VecI->getParent (),
2874
2874
std::next (VecI->getIterator ()));
@@ -2878,8 +2878,8 @@ BoUpSLP::vectorizeTree(ExtraValueToDebugLocsMap &ExternallyUsedValues) {
2878
2878
Value *Ex = Builder.CreateExtractElement (Vec, Lane);
2879
2879
Ex = extend (ScalarRoot, Ex, Scalar->getType ());
2880
2880
CSEBlocks.insert (cast<Instruction>(Scalar)->getParent ());
2881
- std::swap ( ExternallyUsedValues[Ex], ExternallyUsedValues[ Scalar] );
2882
- assert ( ExternallyUsedValues[Scalar]. empty ()) ;
2881
+ ExternallyUsedValues. erase ( Scalar);
2882
+ ExternallyUsedValues[Ex] = DL ;
2883
2883
continue ;
2884
2884
}
2885
2885
@@ -4439,11 +4439,9 @@ class HorizontalReduction {
4439
4439
Builder.setFastMathFlags (Unsafe);
4440
4440
unsigned i = 0 ;
4441
4441
4442
- BoUpSLP::ExtraValueToDebugLocsMap ExternallyUsedValues;
4443
- // The same extra argument may be used several time, so log each attempt
4444
- // to use it.
4442
+ MapVector<Value *, DebugLoc> ExternallyUsedValues;
4445
4443
for (auto &Pair : ExtraArgs)
4446
- ExternallyUsedValues[Pair.second ]. push_back ( Pair.first ->getDebugLoc () );
4444
+ ExternallyUsedValues[Pair.second ] = Pair.first ->getDebugLoc ();
4447
4445
while (i < NumReducedVals - ReduxWidth + 1 && ReduxWidth > 2 ) {
4448
4446
auto VL = makeArrayRef (&ReducedVals[i], ReduxWidth);
4449
4447
V.buildTree (VL, ExternallyUsedValues, ReductionOps);
@@ -4491,14 +4489,9 @@ class HorizontalReduction {
4491
4489
Builder.CreateBinOp (ReductionOpcode, VectorizedTree, I);
4492
4490
}
4493
4491
for (auto &Pair : ExternallyUsedValues) {
4494
- if (Pair.second .empty ())
4495
- continue ;
4496
- // Add each externally used value to the final reduction.
4497
- for (auto &DL : Pair.second ) {
4498
- Builder.SetCurrentDebugLocation (DL);
4499
- VectorizedTree = Builder.CreateBinOp (ReductionOpcode, VectorizedTree,
4500
- Pair.first , " bin.extra" );
4501
- }
4492
+ Builder.SetCurrentDebugLocation (Pair.second );
4493
+ VectorizedTree = Builder.CreateBinOp (ReductionOpcode, VectorizedTree,
4494
+ Pair.first , " bin.extra" );
4502
4495
}
4503
4496
// Update users.
4504
4497
if (ReductionPHI && !isa<UndefValue>(ReductionPHI)) {
0 commit comments