[PATCH] D133676: [X86] Simplify isReplaceable (NFC)

Phoebe Wang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 13 22:44:28 PDT 2022


pengfei added inline comments.


================
Comment at: llvm/lib/Target/X86/X86OptimizeLEAs.cpp:464
     // the LEA is not replaceable.
-    if (!isIdenticalOp(MI.getOperand(MemOpNo + X86::AddrBaseReg), MO))
+    if (&MO != &MI.getOperand(MemOpNo + X86::AddrBaseReg))
       return false;
----------------
kazu wrote:
> pengfei wrote:
> > This cannot prevent def register been used by other operands at the same time.
> > This cannot prevent def register been used by other operands at the same time.
> 
> Sure, a single iteration of the "for" loop may not prevent the def register being used by other operands, but if we check to see if all uses are used as the address base register, then no use is left for any other purpose.  Or it it possible that some uses are not counted in the use list?
I see your point. But I don't know. I have some concerns, e.g., if their pointer are always unique? It is fragile given not guaranteed by API/doc. And if pointer comparison is stable enough, why is [[ https://llvm.org/doxygen/MachineOperand_8cpp_source.html#l00296 | isIdenticalTo ]] implemented in a complex way?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133676



More information about the llvm-commits mailing list