[PowerPC] Optimize compare by using record form in post-RA.
authoresmeyi <esme.yi@ibm.com>
Mon, 31 Oct 2022 05:33:50 +0000 (01:33 -0400)
committeresmeyi <esme.yi@ibm.com>
Mon, 31 Oct 2022 05:33:50 +0000 (01:33 -0400)
commitd1115c2b84d42eefd1546463507ce84f45c6b7cd
tree0b14d1060334a32315a52b70bbc71298b0ed593d
parentcb33ef7ca71d864b5fb8efbe59d77e895ba6e9a0
[PowerPC] Optimize compare by using record form in post-RA.

Summary: We currently optimize the comparison only in SSA, therefore we will miss some optimization opportunities where the input of comparison is lowered from COPY in post-RA.
Ie. ExpandPostRA::LowerCopy is called after PPCInstrInfo::optimizeCompareInstr.
This patch optimizes the comparison in post-RA and only the cases that compare against zero can be handled.
D131374 converts the comparison and its user to a compare against zero with the appropriate predicate on the branch, which creates additional opportunities for this patch.

Reviewed By: shchenz, lkail

Differential Revision: https://reviews.llvm.org/D131873
llvm/lib/Target/PowerPC/PPCInstrInfo.cpp
llvm/lib/Target/PowerPC/PPCInstrInfo.h
llvm/lib/Target/PowerPC/PPCPreEmitPeephole.cpp
llvm/test/CodeGen/PowerPC/opt-cmp-rec-postra.mir [new file with mode: 0644]
llvm/test/CodeGen/PowerPC/ppc64-rop-protection.ll