[llvm] [MCP] Enhance MCP copy Instruction removal for special case (PR #70778)

via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 31 06:17:02 PDT 2023


================
@@ -735,6 +736,27 @@ void MachineCopyPropagation::ForwardCopyPropagateBlock(MachineBasicBlock &MBB) {
         MCRegister Def = RegDef.asMCReg();
         MCRegister Src = RegSrc.asMCReg();
 
+        // Target may lost some opportunity to further remove the redundant
+        // copy instruction, consider the following sequence:
+        // L1: r0 = COPY r9     <- TrackMI
+        // L2: r0 = COPY r8     <- TrackMI
----------------
LWenH wrote:

Yeah, I agree with you.  This's still not a very general method to fix this issue here. But I think it's a good place to discuss a more robust way to fix this issue here. 

The root cause of this issue is that the tracker will invalidate L2 rather than L1 in tracker when we reach L4. When we reach L2, the current mechanism in **ForwardCopyPropagateBlock** will not remove L1 in tracker anyway, so if we unrelated L1 and L2, I think we could remove the **record of def** in tracker to fix this problem.

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


More information about the llvm-commits mailing list