[PATCH] D131873: [PowerPC] Optimize compare by using record form in post-RA.

ChenZheng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 24 22:35:59 PDT 2022


shchenz added a comment.

Compared with previous versions, to me, seems some valid transformations are gone now because of the new bail out case `Subtarget.isPPC64() && Opc == PPC::CMPWI`. Maybe we can have a further check why PPC64 generates `CMPWI 0` for some cases. For these cases, I believe `CMPDI 0` should also be ok, so that there will be more record form opportunities here. But we can do that in another patch.



================
Comment at: llvm/lib/Target/PowerPC/PPCInstrInfo.cpp:2779
+  if (!analyzeCompare(CmpMI, SrcReg, SrcReg2, CmpMask, CmpValue) ||
+      SrcReg.isVirtual() || SrcReg2.isVirtual())
+    return false;
----------------
We don't need the check for `isVirtual()`? we are post-ra here.


================
Comment at: llvm/lib/Target/PowerPC/PPCInstrInfo.cpp:2791
+  unsigned Opc = CmpMI.getOpcode();
+  if (Opc == PPC::CMPLWI || (Subtarget.isPPC64() && Opc == PPC::CMPLDI))
+    return false;
----------------
Maybe we don't need `Subtarget.isPPC64()` for  `PPC::CMPLDI` because this should be impossible.


================
Comment at: llvm/lib/Target/PowerPC/PPCInstrInfo.cpp:2839
+  if (SrcRegHasOtherUse || CmpMI.getOperand(1).isKill())
+    fixupIsDeadOrKill(SrcMI, &CmpMI, SrcReg);
+
----------------
hmm, another caller of `fixupIsDeadOrKill()`, we refactor this in D133103. FYI @nemanjai 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D131873/new/

https://reviews.llvm.org/D131873



More information about the llvm-commits mailing list