Use more context to prove contextual facts about the last iteration. It is
only executed when the backedge is taken, so we can use isLoopBackedgeGuardedByCond
to make this check.
Details
Diff Detail
Event Timeline
llvm/lib/Analysis/ScalarEvolution.cpp | ||
---|---|---|
9642 | The only concern I have: whether isLoopBackedgeGuardedByCond always produces better result than isKnownPredicateAt. |
llvm/lib/Analysis/ScalarEvolution.cpp | ||
---|---|---|
9642 | I ran 4077 fuzzer-generated test with assert that whenever the new condition is false, the old condition is also false. Theoretically, this might happen. But it's just a reason to make isLoopBackedgeGuardedByCond smarter. |
llvm/lib/Analysis/ScalarEvolution.cpp | ||
---|---|---|
9642 | I hope no one test failed :) |
Yes, I ran 4077 fuzz tests checking this assumption, and it seems better in every case there. There can theoretically be cases where isLoopBackedgeGuardedBy is weaker, but it's only the reason to improve it.
Eeek. I found a test where isKnownPredicateAt is more powerful. Need to use both then.
Actually, it only means that isLoopBackedgeGuardedByCond should directly call isKnownPredicateAt(Latch->getTerminator()) as the last resort. I will follow-up with this improvement adding relevant test.
The only concern I have: whether isLoopBackedgeGuardedByCond always produces better result than isKnownPredicateAt.