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

            Bug ID: 112670
           Summary: RISC-V: Run fail on pr65518.c with -flto
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: juzhe.zhong at rivai dot ai
  Target Milestone: ---

Case:

#include <assert.h>

#if VECTOR_BITS > 256
#define NINTS (VECTOR_BITS / 32)
#else
#define NINTS 8
#endif

#define N (NINTS * 2)
#define RESULT (NINTS * (NINTS - 1) / 2 * N + NINTS)

typedef struct giga
{
  unsigned int g[N];
} giga;

unsigned long __attribute__((noinline,noclone))
addfst(giga const *gptr, int num)
{
  unsigned int retval = 0;
  int i;
  for (i = 0; i < num; i++)
    retval += gptr[i].g[0];
  return retval;
}

int main ()
{
  struct giga g[NINTS];
  unsigned int n = 1;
  int i, j;
  for (i = 0; i < NINTS; ++i)
    for (j = 0; j < N; ++j)
      {
        g[i].g[j] = n++;
        __asm__ volatile ("");
      }
  assert (addfst (g, NINTS) == RESULT);
  return 0;
}

with -march=rv64gcv_zvfh_zfh_zvl512b -mabi=lp64d -O3 -fno-vect-cost-model
The run passed.

However, with -march=rv64gcv_zvfh_zfh_zvl512b -mabi=lp64d -O3
-fno-vect-cost-model -flto.

It execution failed:
bbl loader
assertion "addfst (g, NINTS) == RESULT" failed: file "bug.c", line 38,
function: main

I compare the codegen, they are totally the same.
I can't figure out what's the problem ?

Reply via email to