From fd8c1779b338e0f20eee7686b58fb539cbce6c4d Mon Sep 17 00:00:00 2001 From: Florian Hahn Date: Sat, 22 Mar 2025 20:44:56 +0000 Subject: [PATCH] [InstCombine] Use MapVector for SourceAggregates. foldAggregateConstructionIntoAggregateReuse iterates over the entries of SourceAggregates and the order of inserted instructions depends on the order of the iterator. Using a regular DenseMap can lead to non-deterministic value naming/numbering. I don't think it can actually impact the generated binary, but it makes diffing IR more difficult. If desired, I could provide a test case showing the difference in naming. --- llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp b/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp index 6860a7cd07b78..f897cc7855d2d 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp @@ -1111,7 +1111,7 @@ Instruction *InstCombinerImpl::foldAggregateConstructionIntoAggregateReuse( // For each predecessor, what is the source aggregate, // from which all the elements were originally extracted from? // Note that we want for the map to have stable iteration order! - SmallDenseMap SourceAggregates; + SmallMapVector SourceAggregates; bool FoundSrcAgg = false; for (BasicBlock *Pred : Preds) { std::pair IV =