https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82991
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |ASSIGNED Last reconfirmed| |2017-11-15 Assignee|unassigned at gcc dot gnu.org |rguenth at gcc dot gnu.org Ever confirmed|0 |1 --- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> --- (In reply to Jakub Jelinek from comment #1) > GCC tracks that fact, see gimple_call_return_flags ERF_RETURNS_ARG and > ERF_RETURN_ARG_MASK to say which argument it is. > From what I can see, it is used during aliasing and vrp (in the latter case > only whether it is non-NULL or not). So it is just a matter of using it in > further optimizations. But it needs to be used with care. > Trying to optimize: > return strcpy (x, y); > as > strcpy (x, y); > return x; > is not a good idea, it would make it not tail-call optimizable, and in many > cases even for RA purposes it is cheaper to read the value from the return > register rather than saving it in call saved register and restoring from > there, etc. Which is why it is not that strightforward to say do it in SCCVN. Yes, I've done it in SCCVN (I belive there's a dup of this PR), also to the effect to transform x = strcpy (y, z); foo (y); to x = strcpy (y, z); foo (x); I can dig up the patch, it must be sitting somewhere on my disk...