[PATCH] D152828: [MachineSink][AArch64] Sink instruction copies when they can replace copy into hard register or folded into addressing mode

Momchil Velikov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 17 02:25:26 PDT 2023


chill added inline comments.


================
Comment at: llvm/lib/Target/AArch64/AArch64InstrInfo.cpp:3264
+      unsigned Opcode = regOffsetOpcode(MemI.getOpcode());
+      // Copy the base register to the correct register class.
+      Register BaseReg = MRI.createVirtualRegister(&AArch64::GPR64spRegClass);
----------------
chill wrote:
> chill wrote:
> > dmgreen wrote:
> > > Would constrainRegClass work too, to avoid the COPY?
> > We come here with virtual register in `AM.BaseReg` in the `GPR64` register class, but the load/store instruction needs a register in the `GPR64sp`, which is not a subclass of `GPR64` (it's less constrained, a superclass).
> > 
> > IIUC, `constrainRegClass` would work in the opposite direction of what we need, from `GPR64sp` to `GPR64`.
> > 
> > Alternatively, that might be fixed in the verifier, to not complain if an operand is not in the exact register class, but is nevertheless in a more constrained class (a subclass).
> All right, having said that, I just tried using `constrainRegClass`  and it worked.  I'll look some more into it.
I see what happens, neither one of `GPR64` or `GPR64sp` is a superclass/subclass of the other as I thought (one has `XZR`  where the other has `SP`). So `constrainRegClass` yields `GPR64common` and the machine verifier already works exactly suggested above.


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

https://reviews.llvm.org/D152828



More information about the llvm-commits mailing list