On Fri, Aug 28, 2020 at 10:48:43AM +0930, Alan Modra wrote: > On Thu, Aug 27, 2020 at 03:17:45PM -0500, Segher Boessenkool wrote: > > On Thu, Aug 27, 2020 at 01:51:25PM -0500, Bill Schmidt wrote: > > It not the copy that is unnecessary: the preventing it *here*, manually, > > is what is unnecessary. > > Blame me for the original !rtx_equal_p in rs6000_call_aix that Bill > copied. So does emit_move_insn prevent the copy? I can't spot where, > maybe I haven't looked hard enough.
It doesn't. But this is generated during expand already, many later passes can optimise it away. > If emit_move_insn doesn't prevent it, then why create useless RTL that > is only going to make work for optimisation passes that remove such > nops? 1) Very many unnecessary moves are generated during expand *anyway*, a few more will not hurt; 2) In practice we always generate a move from a pseudo into r12 here, never a copy from r12 into r12; 3) Why generate dead code optimising cases that do not happen, making the compiler bigger and slower, but more importantly, making the compiler code harder to read? Such optimisations can be useful for code we generate very late, but not for stuff run at expand. It is distracting to the reader, who then can think a copy from r12 to r12 can happen here, and even is frequent enough to warrant a special optimisation. Older GCC was chock-full of such questionable micro-optimisations. But imo we should try to make the code base more modern now. Segher