[PATCH] D60209: If conversion to conditional select for -Oz or -Os unprofitable for single operation blocks

Ramakota Reddy via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 3 09:11:04 PDT 2019


ramred01 created this revision.
ramred01 added reviewers: lattner, iteratee, stoklund.
Herald added a subscriber: javed.absar.

When we are compiling for -Os or -Oz, performing if conversion to conditional select when the two branches of the if have exactly one instruction in them tends to generate more code.

We prevent it at three stages.  The first is in early if conversion.  We count the number of instructions in each block and if it is less than two we return without changes.

The next is in the tail duplicator.  If there are no select or GEP instructions in the layout predecessor of the tail duplicated block, then we do not splice the tail duplicated block into the layout predecessor.  This prevents generation of some unnecessary branches.

The third is in simplify CFG.  If the if statement results in a two entry PHI node at the beginning of a basic block, then we try to fold it into a SELECT.  In case the incoming edges to the PHI node are from basic blocks having exactly one instruction, we prevent the generation of this SELECT.


https://reviews.llvm.org/D60209

Files:
  lib/CodeGen/EarlyIfConversion.cpp
  lib/CodeGen/TailDuplication.cpp
  lib/CodeGen/TailDuplicator.cpp
  lib/Transforms/Utils/SimplifyCFG.cpp
  test/CodeGen/AArch64/branches_are_betterthan_csels.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60209.193511.patch
Type: text/x-patch
Size: 8073 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190403/50432052/attachment.bin>


More information about the llvm-commits mailing list