[PATCH] Fix for bug in indvars/ SCEV generating infinite loop (pr18886)

Andrew Trick atrick at apple.com
Wed May 21 18:37:10 PDT 2014


Hi Dinesh, thanks for working on this. I just started reviewing your fix right after committing r209358 as a fix for pr19799. It looks like my fix actually handles both test cases. It's really unfortunate that I did not pay attention to pr18886 which was filed much earlier.

I do approve your test case pr18886.ll, would you mind checking that in.

Now let me explain that code.

Before dividing the recurrence's distance by its step, we first check SCEV::FlagNW. This means that the recurrence cannot wrap around past its initial value. So, when we compute the ExitLimit we can assume that the test is not skipped. We do correctly set MustExit=false, which indicates that this loop exit test may be skipped. The value that we use here for ExitLimit is then the number of non-exiting iterations that may occur before exiting the loop via this specific exit. If we exit via another branch, then the value is really meaningless.

The real bug in this case was the way I was summarizing the max backedge count based on the max exit limit from multiple loop exits, which is what my checkin fixed.

http://reviews.llvm.org/D3837






More information about the llvm-commits mailing list