This is an archive of the discontinued LLVM Phabricator instance.

[LoopUnroll] Reorder code to max dom tree update more obvious [nfc]
ClosedPublic

Authored by reames on Jun 2 2021, 3:02 PM.

Details

Summary

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.

Diff Detail

Event Timeline

reames created this revision.Jun 2 2021, 3:02 PM
reames requested review of this revision.Jun 2 2021, 3:02 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 2 2021, 3:02 PM
reames retitled this revision from [LoopUnroll] Reorder code to max dom tree update more obvious [nfc[ to [LoopUnroll] Reorder code to max dom tree update more obvious [nfc].Jun 2 2021, 6:18 PM
nikic accepted this revision.Jun 3 2021, 9:43 AM

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.

This revision is now accepted and ready to land.Jun 3 2021, 9:43 AM
This revision was landed with ongoing or failed builds.Jun 3 2021, 10:20 AM
This revision was automatically updated to reflect the committed changes.