[PATCH] D157564: [MCP] Invalidate copy for super register in copy source

Jeffrey Byrnes via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 10 10:25:15 PDT 2023


jrbyrnes added inline comments.


================
Comment at: llvm/lib/CodeGen/MachineCopyPropagation.cpp:210
+      if (!is_contained(Copy.SrcRegs, Src))
+        Copy.SrcRegs.push_back(Src);
       Copy.LastSeenUseInCopy = MI;
----------------
arsenm wrote:
> I don't see how SrcRegs is used any differently. Should this just use a more normal looking liveness scan where there's only one set and each def removes the live uses?
> I don't see how SrcRegs is used any differently.



MCP currently works s.t. if a source or dest of some MI partially overlaps the source or dest of an active, then we say that the copy is no longer active across all its def regunits. In other words, we don't allow partial copy propagation. This is what `Copy.DefRegs` is used for, if we come across an MI with regunit that partially overlaps with some previous copy, we query the map to get the `Copy` structure, then we invalidate it for all the RegUnit in `Def` where `Def` is just the dest register in the actual copy.

However, we don't do the same for the src RegUnits of the copy. Enabling such is the intention behind `Copy.SrcRegs`. As is, if an MI has registers (B) which partially overlaps the source of a Copy (A), a subsequent MI will find that Copy is still active if it has registers that are in the difference A - B.

In short, `Copy.SrcRegs` holds the Source Reg of the copy, so that when we mark a copy as invalid, we can do so across all regunits in its source.

>Should this just use a more normal looking liveness scan where there's only one set and each def removes the live uses

The tracker for backwardCopyProp really needs to track 3 things:


# "Activeness" of the uses of the copies. This is really just liveness, however any partial clobbering should say the full set of RegUnits involved in the use is inactive.
# Validity of propagation -- 
 # Uses of copy uses - if we want to propagate a copy backwards, then we will replace `DEF A; B = COPY A` with -> `DEF B`. But, if there are any uses of A between the `DEF` and the `COPY` then the propagation is not longer valid.
 # Uses of copy defs - If we have done the above propagation, and there is a user of B between the propagation site and the COPY, then we will have clobbered.






I think we can identify 1 and 2A with a tracker that does something that looks like a backwards liveness scan, however, I don't think we can capture 2B.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157564



More information about the llvm-commits mailing list