On 30/10/17 13:54, Wilco Dijkstra wrote:
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?

Thanks, that makes sense.
Ok for trunk.

Thanks,
Kyrill

Wilco

Reply via email to