This patch teaches SCEV two implication rules:
x <u y && y >=s 0 --> x <s y, x <s y && y <s 0 --> x <u y.
And all equivalents with signs/parts swapped.
Paths
| Differential D110517
[SCEV] Prove implication of predicates to their sign-flipped counterparts ClosedPublic Authored by mkazantsev on Sep 26 2021, 10:47 PM.
Details Summary This patch teaches SCEV two implication rules: x <u y && y >=s 0 --> x <s y, x <s y && y <s 0 --> x <u y. And all equivalents with signs/parts swapped.
Diff Detail
Event Timelinemkazantsev added a child revision: D110518: [SCEV] Prove isKnown(Non)Negative using CtxI when possible.Sep 26 2021, 11:05 PM
mkazantsev added inline comments.
mkazantsev retitled this revision from [SCEV] Prove implication X <u Y, Y >=s 0 --> X <s Y to [SCEV] Prove implication of predicates to their sign-flipped counterparts. Comment ActionsGeneralized as widely as I could, now this covers all varieties of these. This revision is now accepted and ready to land.Oct 14 2021, 12:14 PM
Closed by commit rG90ae538cab4b: [SCEV] Prove implication of predicates to their sign-flipped counterparts (authored by mkazantsev). · Explain WhyOct 14 2021, 9:49 PM This revision was automatically updated to reflect the committed changes.
Revision Contents
Diff 379916 llvm/lib/Analysis/ScalarEvolution.cpp
llvm/test/Transforms/IndVarSimplify/outer_phi.ll
|
This looks correct to me, but also rather ad-hoc -- it handles one out of multiple symmetrical patterns. For example, if we just swap both predicates (Pred == SGT and non-negative LHS) this will not trigger anymore. Or did that already get canonicalized away (in which case we should test it)?