This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
RE: Legitimacy of replacing divide-by-power-of-2 with right shifts.
- From: "Dave Korn" <dave dot korn at artimi dot com>
- To: "'Alan Modra'" <amodra at bigpond dot net dot au>
- Cc: <gcc at gcc dot gnu dot org>
- Date: Fri, 21 Apr 2006 13:22:13 +0100
- Subject: RE: Legitimacy of replacing divide-by-power-of-2 with right shifts.
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 yourself a new compiler. :)
>
> 2006-04-19 Alan Modra <amodra@bigpond.net.au>
>
> PR rtl-optimization/26026
> * fold-const.c (fold_binary): Optimize div and mod where the divisor
> is a known power of two shifted left a variable amount.
Thanks Alan, nice one! I'm working with a 3.3 series legacy codebase so
I'll need to backport it (the 'keep-everything-stable' dept. would have
kittens if I suggest moving up to 4.x without having a few spare months for
testing and stabilisation :-/) but that looks trivial (noticed there's a
return t -vs- return NULL_TREE difference between 3.x and 4.x in a few places,
think I can guess what that's all about, the rest should go through unchanged
AFAICS) and I'll pick up a few of the other new improvements while I'm there.
I was just worried there might be some corner case where it wasn't a valid
transformation but I guess the standard does place such restrictions on valid
shifts that any such cases would be undefined behaviour anyway. Thanks again.
<scurries off to test shiny new compiler with big smile on face>
cheers,
DaveK
--
Can't think of a witty .sigline today....