diff --git a/llvm/lib/Target/RISCV/RISCVFrameLowering.cpp b/llvm/lib/Target/RISCV/RISCVFrameLowering.cpp --- a/llvm/lib/Target/RISCV/RISCVFrameLowering.cpp +++ b/llvm/lib/Target/RISCV/RISCVFrameLowering.cpp @@ -267,9 +267,10 @@ Register MaxPushPopReg = RISCV::NoRegister; PushPopRegs = 0; for (auto &CS : CSI) { - Register Reg = CS.getReg(); - if (RISCV::PGPRRegClass.contains(Reg)) { - MaxPushPopReg = std::max(MaxPushPopReg.id(), Reg.id()); + // RISCVRegisterInfo::hasReservedSpillSlot assigns negative frame indices to + // registers which can be saved by Zcmp Push. + if (CS.getFrameIdx() < 0) { + MaxPushPopReg = std::max(MaxPushPopReg.id(), CS.getReg().id()); PushPopRegs += 1; } } diff --git a/llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp b/llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp --- a/llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp +++ b/llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp @@ -132,7 +132,7 @@ } // Frame indexes representing locations of CSRs which are given a fixed location -// by save/restore libcalls. +// by save/restore libcalls or Zcmp Push/Pop. static const std::pair FixedCSRFIMap[] = { {/*ra*/ RISCV::X1, -1}, {/*s0*/ RISCV::X8, -2}, diff --git a/llvm/lib/Target/RISCV/RISCVRegisterInfo.td b/llvm/lib/Target/RISCV/RISCVRegisterInfo.td --- a/llvm/lib/Target/RISCV/RISCVRegisterInfo.td +++ b/llvm/lib/Target/RISCV/RISCVRegisterInfo.td @@ -165,15 +165,6 @@ def SR07 : GPRRegisterClass<(add (sequence "X%u", 8, 9), (sequence "X%u", 18, 23))>; -// Registers saveable by PUSH/POP instruction in Zcmp extension -def PGPR : RegisterClass<"RISCV", [XLenVT], 32, (add - (sequence "X%u", 8, 9), - (sequence "X%u", 18, 27), - X1 - )> { - let RegInfos = XLenRI; -} - // Floating point registers let RegAltNameIndices = [ABIRegAltName] in { def F0_H : RISCVReg16<0, "f0", ["ft0"]>, DwarfRegNum<[32]>;