This is an archive of the discontinued LLVM Phabricator instance.

[IVUsers] Move preheader check into SCEVExpander
ClosedPublic

Authored by nikic on Oct 12 2021, 2:29 PM.

Details

Summary

Rather than checking for loop nest preheaders upfront in IVUsers, move this requirement into isSafeToExpand() from SCEVExpander, which seems like logically the right place for this check.

This is a followup to https://reviews.llvm.org/D111493#3055286.

Diff Detail

Event Timeline

nikic created this revision.Oct 12 2021, 2:29 PM
nikic requested review of this revision.Oct 12 2021, 2:29 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 12 2021, 2:29 PM

That's amazing that no test shows difference. Do you expect it to be a 100% NFC?

If I'm reading this correctly, isPreheaderLoopNest may find a loop that is dominating, but not containing a given block, and then bail if it doesn't have a preheader. This logic is kind of strange, but I don't really understand its implications.

LGTM.

Have to admit, this is slightly more delicate than I'd realized. Not sure I'd have pushed for this if I realized at the time it had to be an expansion safety predicate as opposed to simply handled (with possibly sub-optimal codegen) during expansion. The benefit seems smaller. Happy to have this land, but would also be fine abandoning this. I'll leave it to your judgement.

nikic updated this revision to Diff 379430.Oct 13 2021, 9:09 AM

Make the check more precise: We can expand affine addrecs in canonical mode without a preheader. This addresses the PowerPC test failure.

On the updated revision, my earlier LGTM still stands, but I'm less and less sure this is worth doing. As previously, I'll defer to your judgement.

This revision was not accepted when it landed; it landed in state Needs Review.Oct 14 2021, 12:53 PM
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.