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

            Bug ID: 125794
           Summary: aarch64: incorrect SVE assembly for loop
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: kristerw at gcc dot gnu.org
            Blocks: 118443
  Target Milestone: ---
            Target: aarch64-unknown-linux-gnu

The test case below fails when compiled for AArch64 with -O2 -march=armv9.5-a:

typedef unsigned V __attribute__((__vector_size__ (32)));

V x;

int
main ()
{
  x[5] = 1;
  for (unsigned i = 0; i < 8; i++)
    if (x[i] != (i == 5))
      __builtin_abort ();
  return 0;
}


The vectorized check for elements x[4] through x[7] is incorrectly emitted as:

        mov     z31.d, #4294967296
        ldr     q30, [x0, 16]
        cmpne   p7.s, p7/z, z30.s, z31.s
        b.any   .L2

The `mov` instruction replicates the 64-bit constant across the entire SVE
vector, which makes the comparison check that both x[5] and x[7] are equal to
1.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118443
[Bug 118443] [Meta bug] Bugs triggered by and blocking more smtgcc testing

Reply via email to