Which pass should be propagating memory copies

Daniel,
You’ve given pretty good arguments for why not to do this in GVN,
How about thinking about other ways to approach the problem

Peter Lawrence.

Hi Peter,
There are of course many ways to approach the problem and anywhere that does it has various trade-offs.
Trying to find any perfect place is a fools errand.
The other obvious place we have is memcpyopt.

FWIW, I don’t think your earlier suggestion of converting it into stores would work

  1. There are always going to be objects large enough that the architecture optimized memcpy is going to be faster, and we aren’t always going to be able to form them back from stores later. So we would never just lower everything to stores.
  2. Because of #1, we’re not going to get rid of memcpy and it’s always going to be valuable to teach these passes how to look through memcpy anyway.