[PATCH] D67794: [MachineCopyPropagation] Extend MCP to do trivial copy backward propagation

Quentin Colombet via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 31 10:29:51 PDT 2019


qcolombet added inline comments.


================
Comment at: llvm/lib/CodeGen/MachineCopyPropagation.cpp:328
+    }
+  }
+  if (!SrcMI || !isSafeBackwardCopyPropagation(Copy, *SrcMI))
----------------
lkail wrote:
> qcolombet wrote:
> > Could you build this information as we iterate into the basic block?
> > I am afraid the compile time cost of this loop to be fairly large otherwise, since we are going to traverse all the instructions between two instructions again and again.
> I find that it might be non-trivial to track information that help perform backward copy propagation in current forward iteration. Would it be a proper option that separating current main loop into two parts, one performs forward copy propagation, the other performs backward copy propagation? i.e.
> ```
>   for (MachineBasicBlock &MBB : MF) {
>     ForwardCopyPropagateBlock(MBB); // Current CopyPropagateBlock
>     BackwardCopyPropagateBlock(MBB);
>   }
> ```
> In `BackwardCopyPropagateBlock`, iterate instructions reversely. Cons is increasing constant complexity.
That would work.
The nice thing about this approach is that we could easily stage the new optimization:
```
for (MachineBasicBlock &MBB : MF) {
  ForwardCopyPropagateBlock(MBB); // Current CopyPropagateBlock
  if (EnableBackwardCP)
    BackwardCopyPropagateBlock(MBB);
}
```


Repository:
  rL LLVM

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

https://reviews.llvm.org/D67794





More information about the llvm-commits mailing list