Sometimes isLoopEntryGuardedByCond cannot prove predicate a > b directly.
But it is a common situation when a >= b is known from ranges and a != b is
known from a dominating condition. Thia patch teaches SCEV to sum these facts
together and prove strict comparison via non-strict one.
Details
- Reviewers
sanjoy jbhateja reames - Commits
- rGb299ade2c5fe: Re-enable "[SCEV] Make isLoopEntryGuardedByCond a bit smarter"
rG69246ca7879d: Revert [SCEV] Make isLoopEntryGuardedByCond a bit smarter
rGdd5ee6f5d9af: [SCEV] Make isLoopEntryGuardedByCond a bit smarter
rL324473: Re-enable "[SCEV] Make isLoopEntryGuardedByCond a bit smarter"
rL324462: Revert [SCEV] Make isLoopEntryGuardedByCond a bit smarter
rL324453: [SCEV] Make isLoopEntryGuardedByCond a bit smarter
Diff Detail
- Repository
- rL LLVM
Event Timeline
lib/Analysis/ScalarEvolution.cpp | ||
---|---|---|
9107 ↗ | (On Diff #132545) | Move this to CmpInst, it already has stuff like CmpInst::getInversePredicate. I'd also s/Loose/NonStrict/ since folks are more likely to be familiar with "strict" than with "loose". |
test/Transforms/IRCE/conjunctive-checks.ll | ||
1 ↗ | (On Diff #132545) | Can you please also add a direct SCEV or IndVars test? |
LGTM with the comment addressed.
lib/Analysis/ScalarEvolution.cpp | ||
---|---|---|
9109 ↗ | (On Diff #132944) | I'm sorry I didn't notice this before, but I think this is better to "fuse" this into the iteration we're already doing instead of recursing (which will walk the dominating checks again). Perhaps extract out a lambda that you call instead of isImpliedCond in this function that has this bit of logic too? |
lib/Analysis/ScalarEvolution.cpp | ||
---|---|---|
9109 ↗ | (On Diff #132944) | isLoopEntryGuardedByCond does traverse over dominating conditions. If we do this, we will have O(N^2) with N being number of dominating blocks. I guess that your point here is that we can be able to prove one fact from assumption and another one from dominating guard. I'm totally fine with that, but I'd rather not fuse it into this loop. I'll give it some thought. How about merging it as is an then making this improvement in separate patch? |
lib/Analysis/ScalarEvolution.cpp | ||
---|---|---|
9109 ↗ | (On Diff #132944) |
Yes -- you could do something like: if you can't prove A < B but can prove A != B, simplify the predicate you're trying to prove to A <= B and continue.
Unless you're blocked on this patch, I'd rather do the right thing now than check in something with the intent to remove it later. |
lib/Analysis/ScalarEvolution.cpp | ||
---|---|---|
9109 ↗ | (On Diff #132944) | Ok, I'll remake it. |
llvm/trunk/lib/Analysis/ScalarEvolution.cpp | ||
---|---|---|
9091 | This assert fails, meaning that the logic of isKnownPredicateViaConstantRanges may be somehow incomplete. We can safely return true here, though. |
This assert fails, meaning that the logic of isKnownPredicateViaConstantRanges may be somehow incomplete. We can safely return true here, though.