MachineInstr - different treatment of subregs for checking mods and reads

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.

1) Just write that function as part of your pass. If it turns out to be useful for more than 1 pass, we can move it to MachineInstr.
2) I'm not 100% sure I understand your motivation, but to me it sounds a bit like you are re-implementing some form of liveness check so why not use LiveRegUnits/LivePhysRegs instead?

- Matthias