[PATCH] D120647: [CGP] Sink compare through freeze

Dave Green via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 28 00:47:44 PST 2022


dmgreen created this revision.
dmgreen added reviewers: spatel, RKSimon, aqjune, nikic.
Herald added subscribers: hiraditya, nemanjai.
dmgreen requested review of this revision.
Herald added a project: LLVM.

CodeGenPrepare will sink most compares to the block that uses then, as an optimization to keep the compare and the branch/select/etc next to on another. This can be blocked by the presence of freeze, however. Usually `freeze(icmp(x, C))` is converted to `icmp(freeze(x), C))`, allowing the cmp to be sunk. If there are multiple uses of the `cmp` though, this currently doesn't happen.

This patch relaxes that, as the cmp will already be duplicated to be sunk into a different block, we can more aggressively convert the icmp-freeze to freeze-icmp.


https://reviews.llvm.org/D120647

Files:
  llvm/lib/CodeGen/CodeGenPrepare.cpp
  llvm/test/CodeGen/PowerPC/select-to-branch.mir
  llvm/test/Transforms/CodeGenPrepare/AArch64/sink-compare-freeze.ll
  llvm/test/Transforms/CodeGenPrepare/X86/freeze-brcond.ll
  llvm/test/Transforms/CodeGenPrepare/X86/select.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D120647.411748.patch
Type: text/x-patch
Size: 14162 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220228/76714fa4/attachment.bin>


More information about the llvm-commits mailing list