diff options
author | Dmitry Makogon <d.makogon@g.nsu.ru> | 2021-11-09 15:41:47 +0700 |
---|---|---|
committer | Dmitry Makogon <d.makogon@g.nsu.ru> | 2021-11-09 16:29:57 +0700 |
commit | ae14fae0ff4304022beda5ab484f84ac0fdda807 (patch) | |
tree | 4f46c4fdc30bc21df50567861a649a44bd25e2b1 /llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp | |
parent | 65431d3aeb9067c5df92827652fbb480859e8078 (diff) | |
download | llvm-ae14fae0ff4304022beda5ab484f84ac0fdda807.zip llvm-ae14fae0ff4304022beda5ab484f84ac0fdda807.tar.gz llvm-ae14fae0ff4304022beda5ab484f84ac0fdda807.tar.bz2 |
[SCEVExpander] Use stable_sort to sort loop Phis in SCEVExpander::replaceCongruentIVs
This is a fix for test failures on expensive checks build caused by db289340c841990055a164e8eb2a3b5ff25677bf.
With LLVM_ENABLE_EXPENSIVE_CHECKS enabled the llvm::sort shuffles the given container.
However, the sort is only called when the TTI is passed to replaceCongruentIVs.
In the mentioned patch we pass it TTI, so the sort happens. But due to shuffling
equivalent Phis may appear in different order from run to run.
With the stable_sort instead of sort this is impossible - the order of sorted Phis
is preserved.
Diffstat (limited to 'llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp index 3abd189..a042146 100644 --- a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp +++ b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp @@ -2022,7 +2022,9 @@ SCEVExpander::replaceCongruentIVs(Loop *L, const DominatorTree *DT, Phis.push_back(&PN); if (TTI) - llvm::sort(Phis, [](Value *LHS, Value *RHS) { + // Use stable_sort to preserve order of equivalent PHIs, so the order + // of the sorted Phis is the same from run to run on the same loop. + llvm::stable_sort(Phis, [](Value *LHS, Value *RHS) { // Put pointers at the back and make sure pointer < pointer = false. if (!LHS->getType()->isIntegerTy() || !RHS->getType()->isIntegerTy()) return RHS->getType()->isIntegerTy() && !LHS->getType()->isIntegerTy(); |