This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] Fix pr14796

On Jun 9, 2005, at 9:48 AM, Richard Henderson wrote:
On Thu, Jun 09, 2005 at 03:29:15PM +0100, Paul Brook wrote:
On Thursday 09 June 2005 14:31, James A. Morrison wrote:

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.

True, so how do we get gcc to generate the best code for both targets? Anyone for TREE_COST?

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]