[PATCH] D110841: [AArch64] Remove redundant ORRWrs which is generated by zero-extend

JinGu Kang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 30 08:18:24 PDT 2021


jaykang10 created this revision.
jaykang10 added reviewers: t.p.northover, dmgreen, efriedma.
Herald added subscribers: hiraditya, kristof.beyls.
jaykang10 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

There are 2 patterns for zero-extend as below.

  //In the case of a 32-bit def that is known to implicitly zero-extend,
  //we can use a SUBREG_TO_REG.
  def : Pat<(i64 (zext def32:$src)),
            (SUBREG_TO_REG (i64 0), GPR32:$src, sub_32)>;
  
  //When we need to explicitly zero-extend, we use a 32-bit MOV instruction
  //and then assert the extension has happened.
  def : Pat<(i64 (zext GPR32:$src)),
            (SUBREG_TO_REG (i32 0), (ORRWrs WZR, GPR32:$src, 0), sub_32)>;

The def32 checks the $src needs explicitly zero-extend. However, it can not check the $src in other block and it adds ORRWrs conservatively in this case. This peephole optimization checks ORRWrs is for redundant zero-extend and try to remove it.


https://reviews.llvm.org/D110841

Files:
  llvm/lib/Target/AArch64/AArch64MIPeepholeOpt.cpp
  llvm/test/CodeGen/AArch64/redundant-mov-from-zero-extend.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D110841.376230.patch
Type: text/x-patch
Size: 5774 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210930/723c5af7/attachment.bin>


More information about the llvm-commits mailing list