[llvm] [Peephole] Check instructions from CopyMIs are still COPY (PR #69511)

via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 19 20:52:04 PDT 2023


================
@@ -1445,7 +1445,9 @@ bool PeepholeOptimizer::foldRedundantCopy(
   }
 
   MachineInstr *PrevCopy = CopyMIs.find(SrcPair)->second;
-  if (!LocalMIs.count(PrevCopy))
+  // A COPY instruction can be deleted or changed by other optimizations.
+  // Check if the previous COPY instruction is existing and still a COPY.
+  if (!LocalMIs.count(PrevCopy) || !PrevCopy->isCopy())
----------------
qcolombet wrote:

Yep, that's exactly what I had in mind

https://github.com/llvm/llvm-project/pull/69511


More information about the llvm-commits mailing list