[PATCH] D40554: [PowerPC] Fix bugs in sign-/zero-extension elimination

Hiroshi Inoue via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 28 06:20:27 PST 2017


inouehrs created this revision.

This patch fixes the following two bugs in `PPCInstrInfo::isSignOrZeroExtended` helper, which is used from sign-/zero-extension elimination in PPCMIPeephole pass.

- Registers defined by load with update (e.g. LBZU) were identified as already sign or zero-extended. But it is true only for the first def (loaded value) and not for the second def (i.e. updated pointer).
- Registers defined by ORIS/ANDIS/XORIS were identified as already sign-extended. But, it is not true for sign extension depending on the immediate (while it is ok for zero extension).

To handle the first case, the parameter for the helpers is changed from `MachineInstr` to a register number to distinguish first and second defs. Also, this patch moves the initialization of PPCMIPeepholePass to allow mir test case.


https://reviews.llvm.org/D40554

Files:
  lib/Target/PowerPC/PPC.h
  lib/Target/PowerPC/PPCInstrInfo.cpp
  lib/Target/PowerPC/PPCInstrInfo.h
  lib/Target/PowerPC/PPCMIPeephole.cpp
  lib/Target/PowerPC/PPCTargetMachine.cpp
  test/CodeGen/PowerPC/sext_elimination.mir

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D40554.124562.patch
Type: text/x-patch
Size: 20934 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171128/e67384ff/attachment.bin>


More information about the llvm-commits mailing list