[patch] Fix pr14796

James A. Morrison ja2morri@csclub.uwaterloo.ca
Thu Jun 9 18:08:00 GMT 2005


Richard Henderson <rth@redhat.com> writes:

> On Thu, Jun 09, 2005 at 03:29:15PM +0100, Paul Brook wrote:
> > On Thursday 09 June 2005 14:31, James A. Morrison wrote:
> > >  Hi,
> > >
> > >   This patch adds some transformations for shifts and rotates such as
> > > (a << c1) << c2 to a << (c1+c2).  This patch has been bootstrapped and
> > > regtested on ia64-linux with no new regressions.  Ok for mainline?
> > +      /* Transform (x >> c1) << c2...  */
> > 
> > +	    /*  ...into (x >> (c1 - c2)) & (-1<<c2).  */
> > 
> > +	    /*  ...into (x & (-1<<c1)) << (c2 - c1).  */
> > 
> > Is this a good idea?
> > There are certainly some targets (eg. Arm) where shifts tend to be cheaper 
> > than masks because the mask can require a constant load, and the shift can be 
> > combined with subsequent instructions.
> 
> Indeed.  Small immediate masks and single-cycle barrel shifters is a
> feature common to many risc machines.  Now, it is something that should
> be considered somewhere, because Intel borked the shifter on P4, and
> the mask+shift is going to be faster there than two shifts.  But you
> can't get at that knowledge at the fold-const level.

 Roger must be using the P4 way too often now, as he suggested the
shift and mask would be cheaper in general than the two shifts.
 
> The only one that's likely to be a win universally is "x >> c << c"
> being transformed to an AND.  The rtl expanders could convert that 
> back to shifts immedately if that were the most efficient way to avoid
> loading a large constant for the mask.

 I can easily go back to only that part.

> According to comment 2 in this pr, "x >> c1 >> c2" is already handled.
> Is this statement false?  If not, why are you handing it again?
> 
> 
> r~

 For one I didn't find that in the code anyway and to quote the author of that
comment:
14:04 < pinskia> Phython: I think comment #2 should say, "when fold"



-- 
Thanks,
Jim

http://www.csclub.uwaterloo.ca/~ja2morri/
http://phython.blogspot.com
http://open.nit.ca/wiki/?page=jim



More information about the Gcc-patches mailing list