[llvm] [LICM][MustExec] Make must-exec logic for IV condition commutative (PR #93150)
Eli Friedman via llvm-commits
llvm-commits at lists.llvm.org
Sat May 25 12:47:09 PDT 2024
efriedma-quic wrote:
We can still use the information, I think?
In the simplest case, we have a loop with a single exit, that we can prove is finite some other way (mustprogress etc.). Then we can just report N+1, because the overflow case would be undefined.
The given testcase is a bit more complicated: you have two exits. But still, we know the loop is finite. The backedge-taken count is something like `umin(zext(OtherExit), zext(N)+1)`. But that's equivalent to `trunc(umin(zext(OtherExit), zext(N)+1))`. And we can simplify that to `umin(OtherExit, umax(N, N+1))`.
Even if we can't prove the loop is finite, recording the information could be useful... see https://github.com/llvm/llvm-project/pull/83052#pullrequestreview-2013190120 .
https://github.com/llvm/llvm-project/pull/93150
More information about the llvm-commits
mailing list