[PATCH] D71829: [PowerPC] Exploit the rlwinm instructions for "and" with constant.

qshanz via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 23 01:01:34 PST 2019


steven.zhang created this revision.
steven.zhang added reviewers: nemanjai, hfinkel, jsji, shchenz, PowerPC.
Herald added subscribers: wuzish, kbarton, hiraditya.
Herald added a project: LLVM.
steven.zhang added a parent revision: D71693: [NFC][PowerPC] Add a function tryAndWithMask.

For now, PowerPC will using several instructions to get the constant and "and" it with the following case:

  define i32 @test1(i32 %a) {
    %and = and i32 %a, -2
    ret i32 %and

However, we could exploit it with the rotate mask instructions.

                 MB  ME
  +----------------------+
  |xxxxxxxxxxx00011111000|
  +----------------------+
   0         32         64

Notice that, we can only do it if the MB is larger than 32 and MB <= ME as RLWINM will replace the content of [0 - 32) with [32 - 64) even we didn't rotate it.


https://reviews.llvm.org/D71829

Files:
  llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCTargetDesc.h
  llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
  llvm/test/CodeGen/PowerPC/and-mask.ll
  llvm/test/CodeGen/PowerPC/opt-cmp-inst-cr0-live.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71829.235106.patch
Type: text/x-patch
Size: 3653 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191223/cce319f3/attachment.bin>


More information about the llvm-commits mailing list