MachineInstr::modifiesRegister() and MachineInstr::readsRegister() seem to disagree on whether to check only the super-reg (reads) or any overlapping register (modifies).
I suppose this makes some sense, but I find it confusing and kind of limiting. I would like to implement something along the lines of MachineInstr::readsAnyOverlappingRegister()
that would have the same semantics other than it would check whether the instruction reads the register, it’s super-register or some sub-register.
Basically, I would just replace TRI->isSubRegister(MOReg, Reg)
in a version of findRegisterUseOperandIdx()
, with TRI->regsOverlap(MOReg, Reg)
. I think this would accomplish what I’m after.
The reason I would find this useful is that I have a pre-emit pass that finds the instruction that defines a register and under certain conditions, I’d be able to remove the defining instruction. But I can’t remove it if there’s another use of any portion of the register between the def and the use I am considering.