[PATCH] D89855: [PowerPC] Combine RLWINM and RLWINM/ANDI_rec before or after RA.

EsmeYi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 21 00:51:59 PDT 2020


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

This patch depends on D89846 <https://reviews.llvm.org/D89846>.
We have the patterns to fold 2 RLWINMs in ppc-mi-peephole, while some RLWINM will be generated after RA, for example rGc4690b007743 <https://reviews.llvm.org/rGc4690b007743d2f564bc1156fdbdbcaad2adddcc>. If the RLWINM generated after RA followed by another RLWINM, we expect to perform the optimization after RA, too.
Besides, RLWINM and ANDI_rec can also be folded.

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/D89855

Files:
  llvm/lib/Target/PowerPC/PPCInstrInfo.cpp
  llvm/lib/Target/PowerPC/PPCMIPeephole.cpp
  llvm/lib/Target/PowerPC/PPCPreEmitPeephole.cpp
  llvm/test/CodeGen/PowerPC/fold-rlwinm.mir
  llvm/test/CodeGen/PowerPC/sms-phi-5.ll
  llvm/test/CodeGen/PowerPC/vsx_builtins.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D89855.299582.patch
Type: text/x-patch
Size: 17328 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201021/42b1b7ac/attachment.bin>


More information about the llvm-commits mailing list