[PATCH] D125335: Give option to use isCopyInstr to determine which MI is treated as Copy instruction in MCP

Kai Luo via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 17 09:36:55 PDT 2022


lkail added inline comments.


================
Comment at: llvm/lib/CodeGen/MachineCopyPropagation.cpp:89
+
+static cl::opt<bool> MCPUseCopyInstr("mcp-use-is-copy-instr", cl::init(false),
+                                     cl::Hidden);
----------------
adriantong1024 wrote:
> lkail wrote:
> > Why do we need this option? Can we extend MCP to check `TII.isCopyInstr` by default?
> I've tried to use isCopyInstr by default, but there are cases which it does not work for some architecture. 
> 
> e.g. ARM
> $lr = tMOVr killed $r1, 14, $noreg
> tBX_RET 14, $noreg, implicit $r0
> 
> isCopyInstr sees tMOVr as a COPY instruction, but the use of $lr is not represented in tBX_RET, so the tMOVr is eliminated.
> 
> So far such problems have not been seen in AArch64.
I mean first we can check `MI.isCopy()`, if `MI.isCopy()` returns `false`, we do further check via `TII->isCopyInstr(MI)`. For the initial draft, we can do simple feasibility check(sufficient to cover your case) on `MI` which `TII->isCopyInstr(MI)` returns `true`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125335



More information about the llvm-commits mailing list