[PATCH] D152502: [MCP] Do not remove redundant copy for COPY from undef

Pierre van Houtryve via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 9 05:00:31 PDT 2023


Pierre-vh added inline comments.


================
Comment at: llvm/lib/CodeGen/MachineCopyPropagation.cpp:466
+  if (PrevCopyOperands->Destination->isDead() ||
+      PrevCopyOperands->Source->isUndef())
     return false;
----------------
arsenm wrote:
> Instead of not doing the fold, can you just strip the undef from the first copy?
I think it should be the same in the end, but`DestSourcePair` only returns const operands, so I can't modify the undef flag from the previous COPY unless I change the members of that class to be non-const, or I directly access `MI.getOperand(1)` but then it defeats the purpose of having an abstraction over COPY instrs operands, IMO

I also think in the end it doesn't really matter, the undef COPY just gets deleted anyway. This is such a niche case already (no tests covered it, and it's only been discovered now randomly) that I would say let's not overthink it, maybe let's just add a TODO for it?




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152502



More information about the llvm-commits mailing list