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

Guozhi Wei via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 20 11:29:30 PDT 2021


Carrot added inline comments.


================
Comment at: llvm/lib/CodeGen/TwoAddressInstructionPass.cpp:661
-    if (!isNew)
-      assert(SrcRegMap[NewReg] == Reg && "Can't map to two src registers!");
     VirtRegPairs.push_back(NewReg);
----------------
craig.topper wrote:
> Is this assert no longer valid?
Yes.
Suppose we have instruction

%102 = ADD killed %100, killed %101

When we process Reg=%100, findOnlyInterestingUse returns NewReg=%102, so a map entry 

SrcRegMap[%102] = %100

is added.
Later when we process Reg=%101, since now we consider commuting operands, findOnlyInterestingUse also returns NewReg=%102, so %102 is mapped to a different register.

SrcRegMap[%102] = %101



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

https://reviews.llvm.org/D108731



More information about the llvm-commits mailing list