[PATCH][GCC] Simplification of 1U << (31 - x)

Wilco Dijkstra Wilco.Dijkstra@arm.com
Thu Apr 13 11:33:00 GMT 2017


Jakub Jelinek wrote:
    
> No.  Some constants sometimes even 7 instructions (e.g. sparc64; not talking
> in particular about 1ULL << 63 constant), or have one instruction
> that is more expensive than normal small constant load.  Compare say x86_64
> movl/movq vs. movabsq, I think the latter has 3 times longer latency on many
> CPUs.  So no, I think it isn't an unconditional win.

We're specifically only talking about the constants (1L << 63), (1 << 31) and (1 << 15).
On all targets these need at most 2 simple instructions. That makes it an unconditional win.

Wilco


More information about the Gcc-patches mailing list