[PATCH] D144687: [GlobalISel][NFC] Add MachineInstr::getFirst[N]{Regs,LLTs}() helpers to extract regs & types.

Amara Emerson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 28 22:55:37 PST 2023


aemerson added a comment.

I’m also wondering for performance reasons whether we should have the types be returned via a single call. With the current patch we call getOperand() twice for each register and I’m not sure if they’ll get optimized to a single call. Maybe:
auto [DstReg, DstTy, Src1Reg, Src1Ty] = MI.getFirst2RegsAndTys();

In D144687#4158579 <https://reviews.llvm.org/D144687#4158579>, @arsenm wrote:

> In D144687#4158484 <https://reviews.llvm.org/D144687#4158484>, @aemerson wrote:
>
>> I’m also wondering for performance reasons whether we should have the types be returned via a single call. With the current patch we call getOperand() twice for each register and I’m not sure if they’ll get optimized to a single call. Maybe:
>> auto [DstReg, DstTy, Src1Reg, Src1Ty] = MI.getFirst2RegsAndTys();
>
> I’ve thought about adding a MachineValue that acts more like an SDValue which would track the type and index

I like the idea in principal, but I worry that it'll be tempting to pass those around as first class values, when they're moreso just ephemerally tied at the point in time. You could imagine a situation where the type of a register is mutated but references to MachineValue being held due to sharing end up stale. With separate registers and types it's harder to fall into that trap.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144687



More information about the llvm-commits mailing list