[PATCH] D11481: [LoopUnswitch] Improve loop unswitch pass to find trivial unswitch conditions more effectively

Chen Li meloli87 at gmail.com
Thu Jul 23 16:29:27 PDT 2015


chenli created this revision.
chenli added reviewers: reames, broune.
chenli added a subscriber: llvm-commits.

This patch improves trivial loop unswitch. 

The current trivial loop unswitch only checks if loop header's terminator contains a trivial unswitch condition. But if the loop header only has one reachable successor (due to intentionally or unintentionally missed code simplification), we should consider the successor as part of the loop header. Therefore, instead of stopping at loop header's terminator, we should keep traversing its successors within loop until reach a *real* conditional branch or switch (whose condition can not be constant folded). This change will enable a single -loop-unswitch pass to unswitch multiple trivial conditions (unswitch one trivial condition could open opportunity to unswitch another one in the same loop), while the old implementation can unswitch only one per pass. 

http://reviews.llvm.org/D11481

Files:
  lib/Transforms/Scalar/LoopUnswitch.cpp
  test/Transforms/LoopUnswitch/infinite-loop.ll
  test/Transforms/LoopUnswitch/trivial-unswitch.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D11481.30537.patch
Type: text/x-patch
Size: 5611 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150723/cd2099a4/attachment.bin>


More information about the llvm-commits mailing list