This is an archive of the discontinued LLVM Phabricator instance.

Use LoopNest as the primary object on which LoopInterchange operates
AcceptedPublic

Authored by TaWeiTu on Mar 3 2021, 3:03 AM.

Details

Reviewers
Whitney
Summary

Replace the usage of LoopList in LoopInterchange completely with LoopNest.
Due to this change, we no longer need to explicitly pass OuterLoop and InnerLoop to processLoop as in D96650.
Also, make interchangeNestedLoops a member function of LoopNest so that LoopNestAnalysis is preserved.

Diff Detail

Event Timeline

TaWeiTu created this revision.Mar 3 2021, 3:03 AM
TaWeiTu requested review of this revision.Mar 3 2021, 3:03 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 3 2021, 3:03 AM
Whitney added inline comments.Mar 8 2021, 6:14 AM
llvm/include/llvm/Analysis/LoopNestAnalysis.h
165

Thinking we should have a more generic set function, like setLoops?

llvm/lib/Transforms/Scalar/LoopInterchange.cpp
504

why this change?

TaWeiTu added inline comments.Mar 8 2021, 6:24 AM
llvm/include/llvm/Analysis/LoopNestAnalysis.h
165

Agreed. But I also think having interchangeNestedLoops here is good in the sense that we can do the asserts below.
Should I add setLoop in this patch?

llvm/lib/Transforms/Scalar/LoopInterchange.cpp
504

Though unrelated to this patch, I think this makes the code a bit clearer since Interchanged is always true when we reach here, and the change seems too trivial for a separate patch.
I can split this into another patch or just push a NFC commit of course, if you think that makes the purpose of this patch clearer.

Whitney added inline comments.Mar 8 2021, 6:33 AM
llvm/include/llvm/Analysis/LoopNestAnalysis.h
165

Can we have a generic set function with a generic assert (guarded by expensive checks macro)?
like assert Loops[0] is the outermost loop, there are no other loops in between Loops[i] and Loops[i+1], Loops[Loops.size()-1] is the innermost loop, etc...

then we can have interchangeNestedLoops in interchange pass?

llvm/lib/Transforms/Scalar/LoopInterchange.cpp
504

I see it now, let's just keep it here.

TaWeiTu added inline comments.Mar 8 2021, 6:51 AM
llvm/include/llvm/Analysis/LoopNestAnalysis.h
165

OK. But I think having a separate patch for that is more appropriate because this patch is primarily about removing the usage of LoopList and synchronizing the API between legacy and new pass manager.
Can I leave interchangeNestedLoops here for now and move it back to LoopInterchange after/in the patch of setLoops?

Whitney added inline comments.Mar 8 2021, 6:52 AM
llvm/include/llvm/Analysis/LoopNestAnalysis.h
165

ok, can you please add a TODO comment?

TaWeiTu updated this revision to Diff 329003.Mar 8 2021, 6:57 AM
  • Add TODOs
TaWeiTu marked 4 inline comments as done.Mar 8 2021, 6:58 AM
TaWeiTu added inline comments.
llvm/include/llvm/Analysis/LoopNestAnalysis.h
165

Thanks! Added TODO.

Whitney accepted this revision.Mar 8 2021, 6:58 AM
This revision is now accepted and ready to land.Mar 8 2021, 6:58 AM