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

            Bug ID: 127075
           Summary: riscv: -mrvv-max-lmul=conv-dynamic causes regression
                    on cpu2017 x264
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: bergner at gcc dot gnu.org
  Target Milestone: ---

The -mrvv-max-lmul=conv-dynamic option causes a perfromance regression on
cpu2017 x264 by choosing an overly large LMUL value leading to spilling when
compared to a smaller LMUL value.  The following test case reduced from x264
shows the problem:

bergner@rvsw-c-02-bergner-18288:X264$ cat bug.c
#include <stdint.h>

void
wide (uint8_t *__restrict a, uint8_t *__restrict b,
      uint8_t *__restrict c, uint8_t *__restrict d,
      int64_t *__restrict o0, int64_t *__restrict o1,
      int64_t *__restrict o2, int64_t *__restrict o3,
      int64_t *__restrict o4, int64_t *__restrict o5, int n)
{
  for (int i = 0; i < n; i++)
    {
      int64_t va = a[i], vb = b[i], vc = c[i], vd = d[i];
      int64_t t0 = va + vb, t1 = vb + vc, t2 = vc + vd, t3 = vd + va;
      int64_t t4 = va * vb, t5 = vb * vc, t6 = vc * vd, t7 = vd * va;
      o0[i] = t0 + t4;
      o1[i] = t1 + t5;
      o2[i] = t2 + t6;
      o3[i] = t3 + t7;
      o4[i] = t0 * t1 + t2 * t3;
      o5[i] = t4 * t5 + t6 * t7;
    }
}

bergner@rvsw-c-02-bergner-18288:X264$ gcc -S -march=rv64gcv -mabi=lp64d -O3
-ftree-vectorize -mno-vector-strict-align -mrvv-max-lmul=conv-dynamic bug.c

Reply via email to