This is the mail archive of the gcc-patches@gcc.gnu.org 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][ARM] Remove DImode expansions for 1-bit shifts


Kyrill Tkachov wrote:
> On 16/10/17 12:30, Wilco Dijkstra wrote:

> > DImode right shifts of 1 are rarely used (6 in total in the GCC binary),
> > so there is little benefit of the arm_ashrdi3_1bit and arm_lshrdi3_1bit
> > patterns.
>
> ... but it's still used, and the patterns were put there for a reason.
> Even if GCC itself doesn't use them much they may be used by other 
> applications.
> 
> So I'd support removing the left shift 1-bit expansions, but not the 
> right shift ones.

The purpose of removing the shift-by-1 cases is not just to cleanup code
but also to improve code generation. These shifts cannot expand early
and thus don't benefit from optimization (like shift merging). They also
suffer from the DImode register allocation issues.

As a simple example this loop runs >20% faster with my patch on both
Cortex-A53 and Cortex-A57 when built with -mfpu=vfp:

long long loop1 (long long x, long long y, int n)
{
  int i;
   for (i = 0; i < n; i++)
   {
      x >>= 1;
      x |= y;
      x >>= 1;
      x |= y;
      x >>= 1;
      x |= y;
      x >>= 1;
      x |= y;
   }
   return x;
}

So given these shifts are bad for performance, why have them at all?

Wilco

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