This is an archive of the discontinued LLVM Phabricator instance.

Incorrect loop limit computation in LFTR
AbandonedPublic

Authored by sanjoy on Jan 23 2015, 1:06 AM.

Details

Summary

In LinearFunctionTestReplace, it seems like if we conclude that it is unsafe to insert a comparison because the induction variable is poison, we don't emit the overflowing addition, but emit the LFTR with an incorrect IVCount anyway. I've added a test case lftr-bad-ivcount.ll that demonstrates the bug.

There are a handful of unit tests that need to be fixed with this change (so if you just apply this patch, make check will fail), but first I'd like to get a sanity check on whether this is a bug or if I've misunderstood something.

Diff Detail

Event Timeline

sanjoy updated this revision to Diff 18652.Jan 23 2015, 1:06 AM
sanjoy retitled this revision from to Incorrect loop limit computation in LFTR.
sanjoy updated this object.
sanjoy edited the test plan for this revision. (Show Details)
sanjoy added reviewers: atrick, majnemer, hfinkel.
sanjoy added a subscriber: Unknown Object (MLST).
sanjoy abandoned this revision.Jan 23 2015, 1:40 AM

I misread the code -- sorry for the noise.

majnemer edited edge metadata.Jan 23 2015, 2:13 AM

Here was my thinking when I wrote the check you are modifying:

  1. If we are going to compare against the post-incremented induction variable, the IndVar had better not have a wrapping flag.
  2. Otherwise, we should compare against the pre-incremented induction variable.

Is there a reason why option number two isn't viable? I assumed that IndVar and BackedgeTakenCount would contain the correct values to compare.

The code is perfectly fine; I just misread it, as I said. :)

I've abandoned the revision on phabricator.

Sent from a mobile device, please excuse typos.