This cleans up the unroll action into two phases. Phase 1 does the mechanical act of unrolling, and leaves all conditional branches in place. Phase 2 optimizes away some of the conditional branches and then simplifies the loop. The primary benefit of the reordering is that we can delete some special cases dom tree update logic.
Details
Details
Diff Detail
Diff Detail
Event Timeline
Comment Actions
I tried this change as well, so have some compile-time numbers for a similar implementation: https://llvm-compile-time-tracker.com/compare.php?from=90310dfff8fd17b0cabdee1fd72d675e5eb2aa78&to=efa3a5246dbf80fca8c79fb7fd9464ba56f51f86&stat=instructions Which shows that impact is minor, though not entirely free. I dropped the change at the time because I didn't find it particularly helpful for followup work (the code is easy to adjust for multiple exit folding).
That said, this LGTM and at least simplifies the code.
llvm/lib/Transforms/Utils/LoopUnroll.cpp | ||
---|---|---|
739 | clang-format warning is legit, some extra indentation snuck in here. |
clang-format: please reformat the code