As noticed by NAKAMURA Takumi back in 2017, we cannot use
properlyDominates for std::stable_sort as properlyDominates only
partially orders blocks. That is, for blocks A, B, C, D, where A
dominates B and C dominates D, we have A == C, B == C, but A < B. This
is not a valid comparison function for std::stable_sort and causes
different results between libstdc++ and libc++. This change uses DFS
numbering to give deterministic results for all reachable blocks.
Unreachable blocks are ignored already, so do not need special
consideration.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Can this be separated into two changes: ignoring unreachable blocks and changing sorting?
If this is approved I can push it as two separate commits, if preferred, but the change to the sorting cannot be done without the ignoring of unreachable blocks, and Phabricator cannot handle changes that depend on other changes as far as I know.
Ah, thanks. Will update once I'm able to re-run tests to also test the change to handling of unreachable blocks in isolation.
llvm/test/Transforms/SLPVectorizer/X86/ordering-bug.ll | ||
---|---|---|
2 | Self generated checks are a pain to maintain (especially in an actively changing component like SLP) - what does it look like if you use the llvm\utils\update_test_checks.py script? |
llvm/test/Transforms/SLPVectorizer/X86/ordering-bug.ll | ||
---|---|---|
2 | It's weird in how it handles block labels, see update. If that makes it much easier to maintain though, it may still be worth it. |
(style) missing assert message