This is an archive of the discontinued LLVM Phabricator instance.

[LoopInterchange] Do not change LI for BBs in child loops.
ClosedPublic

Authored by fhahn on Apr 23 2018, 9:40 AM.

Details

Summary

If a loop with child loops becomes our new inner loop after
interchanging, we only need to update LoopInfo for the blocks defined in
the old outer loop. BBs in child loops will stay there.

Diff Detail

Event Timeline

fhahn created this revision.Apr 23 2018, 9:40 AM
fhahn added a comment.Apr 23 2018, 9:43 AM

LoopInterchange did that wrong and this additional assertion catches that. The fix for LoopInterchange is at D45970

Needs testcase.

LoopInterchange did that wrong and this additional assertion catches that. The fix for LoopInterchange is at D45970

Did you mean to post this on a different patch?

Needs testcase.

tests/Transform/LoopInterchange/phi-ordering.ll has a loop nest with 3 levels deep that gets interchanged twice and exposes the problem. With D45971, -verify-loop-info on the test case should fail (and I think there is another test case that also fails with D45971). I am happy to add a separate test case, in case you think that's valuable.

LoopInterchange did that wrong and this additional assertion catches that. The fix for LoopInterchange is at D45970

Did you mean to post this on a different patch?

Yes, I meant to post this on D45971...

efriedma accepted this revision.Apr 23 2018, 12:39 PM

LGTM

I'm not really happy with LoopInterchangeTransform::restructureLoops overall; it seems like complicated, fragile code. But I don't see a better alternative.

This revision is now accepted and ready to land.Apr 23 2018, 12:39 PM
fhahn added a comment.Apr 23 2018, 2:05 PM

LGTM

I'm not really happy with LoopInterchangeTransform::restructureLoops overall; it seems like complicated, fragile code. But I don't see a better alternative.

Thanks Eli. It is not ideal.... Maybe there's potential for a more generic API to update LoopInfo, but the things we need to update here seem quite specific to interchanging.

This revision was automatically updated to reflect the committed changes.