This is an archive of the discontinued LLVM Phabricator instance.

[polly] Fix SCEVLoopAddRecRewriter to avoid invalid AddRecs.
ClosedPublic

Authored by efriedma on May 21 2021, 5:12 PM.

Details

Summary

When we're remapping an AddRec, the AddRec constructed by a partial rewrite might not make sense. This triggers an assertion complaining it's not loop-invariant.

Instead of constructing the partially rewritten AddRec, just skip straight to calling evaluateAtIteration.

Testcase was automatically reduced using llvm-reduce, so it's a little messy, but hopefully makes sense.

Diff Detail

Event Timeline

efriedma created this revision.May 21 2021, 5:12 PM
efriedma requested review of this revision.May 21 2021, 5:12 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 21 2021, 5:12 PM

This only changes code in ScalarEvolution, so is this a SCEV fix or was Polly using ScalarEvolution in a way that was not originally intended?

SCEVLoopAddRecRewriter was originally added for use by polly, and has only ever been used by polly. So the "original intent" is just whatever polly needed, I think.

Meinersbur accepted this revision.May 27 2021, 6:09 PM

The test is sufficient for me. Thank you for the fix.

This revision is now accepted and ready to land.May 27 2021, 6:09 PM
This revision was landed with ongoing or failed builds.Jun 1 2021, 9:51 AM
This revision was automatically updated to reflect the committed changes.