[llvm] [IndVars] Strengthen inference of samesign flags (PR #170363)
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 3 07:55:46 PST 2025
preames wrote:
> > Using CVP and InstCombine as a reference, we need to be careful to not allow eq/ne comparisons. I'm a bit unclear on the why of that, and for now am going with the low risk change. I may return to investigate that in a follow up.
>
> Using samesign on eq/ne is legal, it's just not really practically useful (as we use it to switch between unsigned and signed comparisons).
Doesn't having it indirectly give us overflow facts? Consider <X,+,Y> !={samesign} W. Without knowing X, Y, or W, doesn't this tell us that the addrec is nsw? From that, don't we also know that such a condition controlling a loop exit is also monotonic (i.e. changes value at most once)?
Not sure how directly useful that is, but it doesn't seem to convey some useful information. Might be worth playing with, particularly in the context of analyzing loops after LFTR.
https://github.com/llvm/llvm-project/pull/170363
More information about the llvm-commits
mailing list