This is an archive of the discontinued LLVM Phabricator instance.

[ScopDetection] Remove redundant checks for endless loops
ClosedPublic

Authored by mreisinger on Sep 14 2016, 6:36 AM.

Details

Summary

Both canUseISLTripCount() and addOverApproximatedRegion() contained checks
to reject endless loops which are now removed and replaced by a single check
in isValidLoop().

For reporting such loops the ReportLoopOverlapWithNonAffineSubRegion is
renamed to ReportLoopHasNoExit. The test case
ReportLoopOverlapWithNonAffineSubRegion.ll is adapted and renamed as well.

Background

The schedule generation in buildSchedule() is based on the following
assumption:

Given some block B that is contained in a loop L and a SESE region R,
we assume that L is contained in R or the other way around.

However, this assumption is broken in the presence of endless loops that are
nested inside other loops. Therefore, in order to prevent erroneous behavior
in buildSchedule(), r265280 introduced a corresponding check in
canUseISLTripCount() to reject endless loops. Unfortunately, it was possible
to bypass this check with -polly-allow-nonaffine-loops which was fixed by adding
another check to reject endless loops in allowOverApproximatedRegion() in
r273905. Hence there existed two separate locations that handled this case.

Thank you Johannes Doerfert for helping to provide the above background
information.

Diff Detail

Event Timeline

mreisinger updated this revision to Diff 71344.Sep 14 2016, 6:36 AM
mreisinger retitled this revision from to [ScopDetection] Remove redundant checks for endless loops [NFC].
mreisinger updated this object.
mreisinger added reviewers: grosser, Meinersbur.
mreisinger added a subscriber: pollydev.
grosser edited edge metadata.Sep 19 2016, 12:03 AM

Hi Matthias,

thank you for this patch. This seems to be indeed a nice cleanup. Great catch. I would like to get some quick feedback from Michael (and maybe even Hui-Hui), who committed the original patch, but I assume we can commit this tomorrow.

It is also nice to see this inspires some additional discussions on how our approach can be improved to better handle such cases. Will be interesting to see what we can learn from this.

Best,
Tobias

Meinersbur accepted this revision.Sep 19 2016, 1:26 AM
Meinersbur edited edge metadata.

This patch looks good. Thank you for suggesting it. However, it is not NFC as the output message changes.

RegionInfo's interpretation of Single-Entry-Single-Exit can be discussed separately. With its current implementation this patch is certainly the right thing to do.

This revision is now accepted and ready to land.Sep 19 2016, 1:26 AM
mreisinger retitled this revision from [ScopDetection] Remove redundant checks for endless loops [NFC] to [ScopDetection] Remove redundant checks for endless loops.Sep 19 2016, 1:30 AM
mreisinger edited edge metadata.
mreisinger updated this object.Sep 19 2016, 1:17 PM
mreisinger added a subscriber: Unknown Object (User).

Thank you for the positive feedback and the discussion! I updated the above summary to reflect the insight that Johannes provided.

Best,
Matthias

mreisinger updated this object.Sep 20 2016, 9:46 AM
grosser closed this revision.Sep 20 2016, 10:15 AM

This was committed in r281987.

test/ScopDetectionDiagnostics/ReportLoopHasNoExit.ll