This patch adds a new LoopNest pass called SimpleLoopNestUnswitch. This pass is similar to SimpleLoopUnswitch, but only unswitches branches out of a whole loop nest. In other words, this pass doesn't make branches in-between loops. This helps create/maintain a perfect loop nest.
See also https://reviews.llvm.org/D104180 for another example of creating a new LoopNest pass of existing passes.
Details
Diff Detail
Event Timeline
If possible, can you let us know what kinds of improvement this patch achieve please? like performance, code size, compile time and etc.
If we remove conditional branch inside loop, it could help loop vectorization. I am not sure the improvement from the perfect loop nest is better than that...
Maybe, other people could give you more good comments.
For example, we may have an opportunity to perform loop-interchange (or some other transformations that require a perfect loop nest) after performing simple-loop-nest-unswitch.
We can perform simple-loop-unswitch after that, so there should be no problem for loop vectorization.
What order we put passes including simple-loop-nest-unswitch in a pass pipeline is still a problem though...
llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp | ||
---|---|---|
2973 | When given BestUnswitchTIForLoopNest, why do we want to findBestUnswitchTI? When given BestUnswitchTIForLoopNest, this code only unswitch if BestUnswitchTIForLoopNest == findBestUnswitchTI. Is it possible that BestUnswitchTIForLoopNest != findBestUnswitchTI only have some loop level? | |
2976 | ||
2982 |
llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp | ||
---|---|---|
2973 | We want to findBestUnswitchTI to obtain PartialIVInfo, ExitBlocks, and BestUnswitchInvariants. However it seems we can remove some code. |
- No longer do findBestUnswitchTI every time we call unswitchBestCondition given BestUnswitchTIForLoopNest.
- Remove the condition BestUnswitchTIForLoopNest == findBestUnswitchTI, which was confusing.
When given BestUnswitchTIForLoopNest, why do we want to findBestUnswitchTI?
When given BestUnswitchTIForLoopNest, this code only unswitch if BestUnswitchTIForLoopNest == findBestUnswitchTI. Is it possible that BestUnswitchTIForLoopNest != findBestUnswitchTI only have some loop level?