[all-commits] [llvm/llvm-project] 874a80: [PowerPC] Exploit the rlwinm instructions for "and...

QingShan Zhang via All-commits all-commits at lists.llvm.org
Sun Dec 29 19:20:30 PST 2019


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 874a8004f93538a0c9b335a7e1e34d80b57ebccd
      https://github.com/llvm/llvm-project/commit/874a8004f93538a0c9b335a7e1e34d80b57ebccd
  Author: QingShan Zhang <qshanz at cn.ibm.com>
  Date:   2019-12-30 (Mon, 30 Dec 2019)

  Changed paths:
    M llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCTargetDesc.h
    M llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
    M llvm/test/CodeGen/PowerPC/and-mask.ll
    M llvm/test/CodeGen/PowerPC/opt-cmp-inst-cr0-live.ll
    M llvm/test/CodeGen/PowerPC/popcnt-zext.ll

  Log Message:
  -----------
  [PowerPC] Exploit the rlwinm instructions for "and" with constant

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.

Differential Revision: https://reviews.llvm.org/D71829




More information about the All-commits mailing list