[PATCH] D90131: [PowerPC] Add folding patterns for rlwinm + andi_rec.

EsmeYi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Oct 25 21:48:56 PDT 2020


Esme created this revision.
Esme added reviewers: steven.zhang, shchenz, jsji, nemanjai, qiucf, lkail, PowerPC.
Herald added subscribers: llvm-commits, kbarton, hiraditya.
Herald added a project: LLVM.
Esme requested review of this revision.

This patch depends on D89855 <https://reviews.llvm.org/D89855>. We have patterns to fold RLWINM + RLWINM.
Pairs of RLWINM and ANDI_rec can also be folded in some cases.
Following is a scenario in C code:

  int tmp = vec_test_swdiv(x,y);
  if (((__builtin_rotateleft32(tmp, 62)) & (1)) != 0){
    ...
  }

`clang -c t.c -O3` generates the sequence:

  xvtdivdp cr0,vs34,vs35
  mfocrf  r3,128
  rlwinm  r3,r3,4,28,31 --->generated in POST-RA
  andi.   r3,r3,4

This patch will fold it to:

  xvtdivdp cr0,vs34,vs35
  mfocrf   r3,128
  rlwinm.  r3,r3,3,31,31


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D90131

Files:
  llvm/lib/Target/PowerPC/PPCInstrInfo.cpp
  llvm/lib/Target/PowerPC/PPCMIPeephole.cpp
  llvm/test/CodeGen/PowerPC/fold-rlwinm-after-ra.mir
  llvm/test/CodeGen/PowerPC/fold-rlwinm.mir
  llvm/test/CodeGen/PowerPC/vsx_builtins.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D90131.300576.patch
Type: text/x-patch
Size: 14083 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201026/a68ad5b2/attachment.bin>


More information about the llvm-commits mailing list