This is an archive of the discontinued LLVM Phabricator instance.

[SCEV] Fix incorrect treatment of max taken count. PR48225
ClosedPublic

Authored by mkazantsev on Nov 23 2020, 12:32 AM.

Details

Summary

SCEV makes a logical mistake when handling EitherMayExit in
case when both conditions must be met to exit the loop. The
mistake looks like follows: "if condition A fails within at most X first
iterations, and B fails within at most Y first iterations, then A & B
fails at most within min (X, Y) first iterations". This is wrong, because
both of them must fail at the same time.

Simple example illustrating this is following: we have an IV with step 1,
condition A = "IV is even", condition B = "IV is odd". Both A and B
will fail within first two iterations. But it doesn't mean that both of them
will fail within first two first iterations at the same time, which would mean
that IV is neither even nor odd at the same time within first 2 iterations.

We can only do so for known exact BE counts, but not for max.

Diff Detail

Event Timeline

mkazantsev created this revision.Nov 23 2020, 12:32 AM
mkazantsev requested review of this revision.Nov 23 2020, 12:32 AM
nikic accepted this revision.Nov 23 2020, 1:15 AM

LGTM

This revision is now accepted and ready to land.Nov 23 2020, 1:15 AM