[PATCH] D36504: [CodeGenPrepare] Convert uncond. branch to return into a return to help with shrink-wrapping
Nemanja Ivanovic via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 8 21:56:13 PDT 2017
nemanjai created this revision.
Currently, CGP will get rid of mostly empty blocks by merging them with their successors. However, in a case where a block `BB` simply branches unconditionally to a block that has no code other than a return, it can be helpful if `BB` just returned since shrink-wrapping might have another candidate for the epilogue.
Example:
...
for.cond.cleanup.loopexit: ; preds = %for.body
br label %for.cond.cleanup
for.cond.cleanup: ; preds = %for.cond.cleanup.loopexit, %entry
%Ret.0.lcssa = phi i32 [ 0, %entry ], [ %0, %for.cond.cleanup.loopexit ]
ret i32 %Ret.0.lcssa
...
Block `for.cond.cleanup.loopexit` can be used for the epilogue if flow has gone through `for.body` whereas block `for.cond.cleanup` can be used for the epilogue if flow never went into the loop.
The patch certainly increases the amount of shrink-wrapping we do. I'm currently running spec on PPC and will post the net change once the results are ready.
Repository:
rL LLVM
https://reviews.llvm.org/D36504
Files:
lib/CodeGen/CodeGenPrepare.cpp
test/CodeGen/MIR/Generic/early-ret-bb.mir
test/CodeGen/PowerPC/early-exit-shrink-wrap.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D36504.110295.patch
Type: text/x-patch
Size: 8333 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170809/fa35862a/attachment.bin>
More information about the llvm-commits
mailing list