https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124769

            Bug ID: 124769
           Summary: Should prefer vshufps to vpermilps when single source
                    not in memory
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: amonakov at gcc dot gnu.org
  Target Milestone: ---
            Target: x86_64-*-*

When AVX is enabled, GCC tends to emit vpermilps instead of vshufps for
single-source vector shuffling. However, vpermilps is useful only when source
vector is in memory, otherwise vshufps with source given as both input operands
is just as fast, and has a shorter encoding.

Testcase for gcc -O2 -mavx:

typedef float vec4 __attribute__((vector_size(16)));

vec4 f(vec4 a)
{
        return __builtin_shufflevector(a, a, 3, 2, 1, 0);
}

vec4 g(vec4 *a)
{
        return __builtin_shufflevector(*a, *a, 3, 2, 1, 0);
}

We want vshufps in 'f' and 'vpermilps' (with memory operand) in 'g'.

Reply via email to