RE: Legitimacy of replacing divide-by-power-of-2 with right shifts.

2006-04-21 Thread Dave Korn
On 21 April 2006 01:10, Alan Modra wrote: > On Thu, Apr 20, 2006 at 04:52:14PM +0100, Dave Korn wrote: >> Yet it would seem to me at first glance that, since dividing unsigned by >> an exact power-of-2 can be optimised to a right shift, and since we can >> deduce > > You might like to build yo

RE: Legitimacy of replacing divide-by-power-of-2 with right shifts.

2006-04-21 Thread Dave Korn
On 20 April 2006 18:28, Kimmo Fredriksson wrote: > On Thu, 20 Apr 2006, Dave Korn wrote: > >> >> Hello, gcc-hackers! >> >> This is somewhat chopped-down from the original code it began life as, but >> it serves to illustrate the point. >> >> unsigned int PhyFrameConfig (unsigned int channel

Re: Legitimacy of replacing divide-by-power-of-2 with right shifts.

2006-04-20 Thread Alan Modra
On Thu, Apr 20, 2006 at 04:52:14PM +0100, Dave Korn wrote: > Yet it would seem to me at first glance that, since dividing unsigned by an > exact power-of-2 can be optimised to a right shift, and since we can deduce You might like to build yourself a new compiler. :) 2006-04-19 Alan Modra <[E

Re: Legitimacy of replacing divide-by-power-of-2 with right shifts.

2006-04-20 Thread Kimmo Fredriksson
On Thu, 20 Apr 2006, Dave Korn wrote: Hello, gcc-hackers! This is somewhat chopped-down from the original code it began life as, but it serves to illustrate the point. unsigned int PhyFrameConfig (unsigned int channelPrf, unsigned int bpp, unsigned int bufferSize) { unsigned int prfShif

RE: Legitimacy of replacing divide-by-power-of-2 with right shifts.

2006-04-20 Thread Dave Korn
On 20 April 2006 17:01, Olivier Galibert wrote: > On Thu, Apr 20, 2006 at 04:52:14PM +0100, Dave Korn wrote: >> Yet it would seem to me at first glance that, since dividing unsigned by >> an exact power-of-2 can be optimised to a right shift, and since we can >> deduce that (1 << bpp) is always

Re: Legitimacy of replacing divide-by-power-of-2 with right shifts.

2006-04-20 Thread Olivier Galibert
On Thu, Apr 20, 2006 at 04:52:14PM +0100, Dave Korn wrote: > Yet it would seem to me at first glance that, since dividing unsigned by an > exact power-of-2 can be optimised to a right shift, and since we can deduce > that (1 << bpp) is always going to be a power-of-2 Isn't that true only if bpp