[PATCH] D20017: Aggressive choosing best loop top

Chuang-Yu Cheng via llvm-commits llvm-commits at lists.llvm.org
Fri May 6 06:06:21 PDT 2016


cycheng created this revision.
cycheng added reviewers: hfinkel, nemanjai, tjablin, kbarton, amehsan, chandlerc, rsandifo, morisset.
cycheng added a subscriber: llvm-commits.

We want to find better loop top for this common (and similar) pattern:

```
           entry               
             |                 
 ------> loop.header (body)    
 |97%    /       \             
 |      /50%      \50%         
 --- latch <--- if.then        
        \    97%  /            
         \3%     /3%           
          loop.end             
```
Currently, Branch Probability Basic Block Placement will generate BlockChain in this order:
entry -> loop.header -> if.then -> latch -> loop.end

This order cause latch needs an branch jumping back to loop.header when condition is true.

Better BlockChain order would be:
entry -> latch -> loop.header -> if.then -> loop.end

So latch can fall through loop.header without this jump.

Thanks Carrot for pointing out this performance issue: https://llvm.org/bugs/show_bug.cgi?id=25782

We also test this patch on Power8 by running SPEC2006, gcc and libquantum get 5% improvements.


http://reviews.llvm.org/D20017

Files:
  lib/CodeGen/AtomicExpandPass.cpp
  lib/CodeGen/MachineBlockPlacement.cpp
  lib/Target/SystemZ/SystemZISelLowering.cpp
  test/CodeGen/AArch64/swifterror.ll
  test/CodeGen/ARM/code-placement.ll
  test/CodeGen/ARM/swifterror.ll
  test/CodeGen/SystemZ/loop-01.ll
  test/CodeGen/SystemZ/swifterror.ll
  test/CodeGen/Thumb2/2010-02-11-phi-cycle.ll
  test/CodeGen/X86/block-placement.ll
  test/CodeGen/X86/code_placement_cold_loop_blocks.ll
  test/CodeGen/X86/code_placement_ignore_succ_in_inner_loop.ll
  test/CodeGen/X86/code_placement_loop_rotation2.ll
  test/CodeGen/X86/compact-unwind.ll
  test/CodeGen/X86/licm-dominance.ll
  test/CodeGen/X86/mbp-false-cfg-break.ll
  test/CodeGen/X86/swifterror.ll
  test/Transforms/AtomicExpand/ARM/atomic-expansion-v7.ll
  test/Transforms/AtomicExpand/ARM/atomic-expansion-v8.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D20017.56406.patch
Type: text/x-patch
Size: 23158 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160506/f5163647/attachment.bin>


More information about the llvm-commits mailing list