[PATCH] D20379: Codegen: Fix broken assumption in Tail Merge.

Kyle Butt via llvm-commits llvm-commits at lists.llvm.org
Thu May 19 11:00:34 PDT 2016


iteratee added inline comments.

================
Comment at: lib/CodeGen/BranchFolding.cpp:1345
@@ -1337,3 +1344,3 @@
     if (MBB->succ_empty() && !PriorCond.empty() && !PriorFBB &&
         MachineFunction::iterator(PriorTBB) == FallThrough &&
         !MBB->canFallThrough()) {
----------------
haicheng wrote:
> If you change FallThrough to MF.end(), I think you may miss this optimization.
> 
> This piece of code tries to optimize this case
> 
> ```
> PrevBB---MBB  FallThrough
>       |____________|
>       
> ```
> Where MBB is the return block, PrevBB is both the layout predecessor and CFG predecessor of MBB, Fallthourgh is just a layout successor of MBB and must *not* be the CFG successor of MBB.  In this case, MBB can be moved to the bottom of the MF and PrevBB can fallthrough to FallThrough.
I moved the test to the empty block removal, which does assume that FallThrough is a CFG successor.


http://reviews.llvm.org/D20379





More information about the llvm-commits mailing list