Skip to content

Commit 215e6be

Browse files
committed
[LV] Use MapVector for ScalarCostsTy for deterministic iter order (NFC)
We iterate over the scalar costs of instruction when printing costs, and currently the iteration order is not deterministic. Currently no tests check the output with multiple instructions in the map, but those will come soon.
1 parent e27831f commit 215e6be

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1590,7 +1590,7 @@ class LoopVectorizationCostModel {
15901590
/// A type representing the costs for instructions if they were to be
15911591
/// scalarized rather than vectorized. The entries are Instruction-Cost
15921592
/// pairs.
1593-
using ScalarCostsTy = DenseMap<Instruction *, InstructionCost>;
1593+
using ScalarCostsTy = MapVector<Instruction *, InstructionCost>;
15941594

15951595
/// A set containing all BasicBlocks that are known to present after
15961596
/// vectorization as a predicated block.
@@ -4992,7 +4992,8 @@ void LoopVectorizationCostModel::collectInstsToScalarize(ElementCount VF) {
49924992
if (!isScalarAfterVectorization(&I, VF) && !VF.isScalable() &&
49934993
!useEmulatedMaskMemRefHack(&I, VF) &&
49944994
computePredInstDiscount(&I, ScalarCosts, VF) >= 0) {
4995-
ScalarCostsVF.insert_range(ScalarCosts);
4995+
for (const auto &[I, IC] : ScalarCosts)
4996+
ScalarCostsVF.insert({I, IC});
49964997
// Check if we decided to scalarize a call. If so, update the widening
49974998
// decision of the call to CM_Scalarize with the computed scalar cost.
49984999
for (const auto &[I, Cost] : ScalarCosts) {

0 commit comments

Comments
 (0)