[llvm] [InstCombine] Fold `(x < y) ? -1 : zext(x != y)` into `u/scmp(x,y)` (PR #101049)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Sat Aug 10 06:49:19 PDT 2024
nikic wrote:
> There's one test that existed before this PR that ended up regressing after I've updated the check lines, it's located in `Transforms/PhaseOrdering/partialord-ule.ll`. One of the selects in that test is folded to `ucmp`, but this then prohibits other optimizations functioning that would've worked on "raw" select. I'm curious to hear any suggestions about how this can be fixed. I can only think of somehow checking whether not folding to ucmp would be more beneficial than doing so, but I can't imagine that being a good solution as it would require running the whole pipeline (or at least an iteration of InstCombine) on two different versions of IR.
We need to implement any missing folds before doing the canonicalization. In this case, what is missing is basically https://alive2.llvm.org/ce/z/Z3YgSo if we view this independently of ucmp/scmp. (If we consider them together, than this would be a variant of ucmp/scmp -> icmp.)
https://github.com/llvm/llvm-project/pull/101049
More information about the llvm-commits
mailing list