How do I stop gcc from loading data into registers when that's not needed?

Richard Biener richard.guenther@gmail.com
Fri May 18 18:07:00 GMT 2018


On May 18, 2018 8:03:05 PM GMT+02:00, Paul Koning <paulkoning@comcast.net> wrote:
>Gents,
>
>In some targets, like pdp11 and vax, most instructions can reference
>data in memory directly.
>
>So when I have "if (x < y) ..." I would expect something like this:
>
>	cmpw  x, y
>	bgeq  1f
>	...
>
>What I actually see, with -O2 and/or -Os, is:
>
>	movw  x, r0
>	movw  y, r1
>	cmpw  r0, r1
>	bgeq  1f
>	...
>
>which is both longer and slower.  I can't tell why this happens, or how
>to stop it.  The machine description has "general_operand" so it
>doesn't seem to be the place that forces things into registers.

I would expect combine to merge the load and arithmetic and thus it is eventually the target costing that makes that not succeed. 

Richard. 

>	paul



More information about the Gcc mailing list