[PATCH] Fix PR middle-end/45416, missing opt for (a&(1<<C))!=0 to (a>>C)&1

Jakub Jelinek jakub@redhat.com
Fri Dec 9 13:01:00 GMT 2011


On Fri, Dec 09, 2011 at 01:50:37PM +0100, Georg-Johann Lay wrote:
> No, not OK.
> 
> This leads to unacceptable code for devices that cannot shift easily like, e.g.
> AVR. This target can only shift by 1 and shifts with big offsets have to be
> performed by means of a loop at runtime.

Andrew's patch only restored what GCC has been doing before.
If this is too expensive on AVR, you should just arrange in the backend to
combine that
((x>>C)&1) != 0
into more efficient code sequence, otherwise people who write
if ((x >> 18) & 1)
  bar ();
in the source will get suboptimal code.

	Jakub



More information about the Gcc-patches mailing list