This is the mail archive of the
mailing list for the GCC project.
Re: [patch] Fix pr14796
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.
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.
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?