[PowerPC] Converts to comparison against zero even when the optimization
authoresmeyi <esme.yi@ibm.com>
Thu, 15 Sep 2022 10:06:25 +0000 (06:06 -0400)
committeresmeyi <esme.yi@ibm.com>
Thu, 15 Sep 2022 10:06:25 +0000 (06:06 -0400)
commit6e0e926c2f12f4897c91a90af61e06f410e528ef
tree8db4be0aa9cd58c69c2a3f692a0f5cc7a82c18e0
parent5279e11f063db6a0cc87ccf9e0e1c7b1b31aa7cf
[PowerPC] Converts to comparison against zero even when the optimization
          doesn't happened in peephole optimizer.

Summary: Converting a comparison against 1 or -1 into a comparison
against 0 can exploit record-form instructions for comparison optimization.
The conversion will happen only when a record-form instruction can be used
to replace the comparison during the peephole optimizer (see function optimizeCompareInstr).

In post-RA, we also want to optimize the comparison by using the record
form (see D131873) and it requires additional dataflow analysis to reliably
find uses of the CR register set.

It's reasonable to common the conversion for both peephole optimizer and
post-RA optimizer.

Converting to comparison against zero even when the optimization doesn't
happened in peephole optimizer may create additional opportunities for the
post-RA optimization.

Reviewed By: nemanjai

Differential Revision: https://reviews.llvm.org/D131374
llvm/lib/Target/PowerPC/PPCInstrInfo.cpp
llvm/test/CodeGen/PowerPC/common-chain.ll
llvm/test/CodeGen/PowerPC/f128-aggregates.ll
llvm/test/CodeGen/PowerPC/loop-instr-form-prepare.ll
llvm/test/CodeGen/PowerPC/loop-instr-prep-non-const-increasement.ll
llvm/test/CodeGen/PowerPC/loop-p10-pair-prepare.ll
llvm/test/CodeGen/PowerPC/pr47373.ll
llvm/test/CodeGen/PowerPC/shrink-wrap.ll
llvm/test/CodeGen/PowerPC/spe.ll
llvm/test/CodeGen/PowerPC/store-constant.ll