[llvm-dev] MachineInstr - different treatment of subregs for checking mods and reads

Nemanja Ivanovic via llvm-dev llvm-dev at lists.llvm.org
Fri Dec 15 06:51:50 PST 2017


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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20171215/6b08a579/attachment.html>


More information about the llvm-dev mailing list