[PATCH] D108731: [TwoAddressInstructionPass] Improve the SrcRegMap and DstRegMap computation

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Sep 18 00:05:12 PDT 2021


craig.topper added inline comments.


================
Comment at: llvm/lib/CodeGen/TwoAddressInstructionPass.cpp:401
+    unsigned Src1 = TII->CommuteAnyOperandIndex;
+    unsigned Src2 = UseMI.findRegisterUseOperandIdx(Reg);
+    if (TII->findCommutedOpIndices(UseMI, Src1, Src2)) {
----------------
craig.topper wrote:
> pengfei wrote:
> > I'm confused about the code here. `findRegisterUseOperandIdx` return `-1` when the function fails. But `-1` is equal to `CommuteAnyOperandIndex`, which means we allow any operand to be commutable?
> I think it should never fail, UseMI is already known to use Reg.
Maybe we should use `use_nodbg_begin` instead of `use_instr_nodbg_begin` earlier to get the `MachineOperand`, then use `MachineOperand::getParent()` to get `UseMI`. Then we can use the `MachineOperand` and `MachineInstr::getOperandNo()` here?


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

https://reviews.llvm.org/D108731



More information about the llvm-commits mailing list