[llvm] [PredicateInfo] Clean up DFS sorting (NFC) (PR #144943)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 19 11:52:48 PDT 2025
================
@@ -175,60 +168,33 @@ struct ValueDFS_Compare {
DomTreeNode *DomBDest = DT.getNode(BDest);
unsigned AIn = DomADest->getDFSNumIn();
unsigned BIn = DomBDest->getDFSNumIn();
- bool isADef = A.Def;
- bool isBDef = B.Def;
- assert((!A.Def || !A.U) && (!B.Def || !B.U) &&
+ bool isAUse = A.U;
+ bool isBUse = B.U;
+ assert((!A.PInfo || !A.U) && (!B.PInfo || !B.U) &&
"Def and U cannot be set at the same time");
// Now sort by edge destination and then defs before uses.
- return std::tie(AIn, isADef) < std::tie(BIn, isBDef);
+ return std::tie(AIn, isAUse) < std::tie(BIn, isBUse);
----------------
nikic wrote:
The previous implementation here was buggy: isADef/isBDef were always false. And if they weren't, this would have sorted the wrong way around.
What saved us here is that the original vector always has the defs before the uses, so the stable sort will preserve the order.
https://github.com/llvm/llvm-project/pull/144943
More information about the llvm-commits
mailing list