[llvm] promote Pseduo Opcode from 32bit to 64bits after eliminating the `extsw` instruction in PPCMIPeepholes optimization (PR #85451)
Amy Kwan via llvm-commits
llvm-commits at lists.llvm.org
Wed May 1 12:08:51 PDT 2024
================
@@ -5234,6 +5234,218 @@ bool PPCInstrInfo::isTOCSaveMI(const MachineInstr &MI) const {
// We limit the max depth to track incoming values of PHIs or binary ops
// (e.g. AND) to avoid excessive cost.
const unsigned MAX_BINOP_DEPTH = 1;
+
+void PPCInstrInfo::replaceInstrAfterElimExt32To64(const Register &Reg,
+ MachineRegisterInfo *MRI,
+ unsigned BinOpDepth,
+ LiveVariables *LV) const {
+ MachineInstr *MI = MRI->getVRegDef(Reg);
+ if (!MI)
+ return;
+
+ unsigned Opcode = MI->getOpcode();
+ bool IsReplaceInstr = false;
+ int NewOpcode = -1;
+
+ auto SetNewOpcode = [&](int NewOpc) {
+ if (!IsReplaceInstr) {
+ NewOpcode = NewOpc;
+ IsReplaceInstr = true;
+ }
+ };
+
+ switch (Opcode) {
+ case PPC::OR:
+ SetNewOpcode(PPC::OR8);
+ [[fallthrough]];
+ case PPC::ISEL:
+ SetNewOpcode(PPC::ISEL8);
+ [[fallthrough]];
+ case PPC::OR8:
+ case PPC::PHI:
+ if (BinOpDepth < MAX_BINOP_DEPTH) {
+ unsigned OperandEnd = 3, OperandStride = 1;
+ if (Opcode == PPC::PHI) {
+ OperandEnd = MI->getNumOperands();
+ OperandStride = 2;
+ }
+
+ for (unsigned I = 1; I != OperandEnd; I += OperandStride) {
----------------
amy-kwan wrote:
It would be better to use `<` instead of `!=` here.
https://github.com/llvm/llvm-project/pull/85451
More information about the llvm-commits
mailing list