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

            Bug ID: 96075
           Summary: bogus alignment for negative step grouped access
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rguenth at gcc dot gnu.org
  Target Milestone: ---

double x[1024], y[1024];

void __attribute__((noipa)) boo()
{
  for (int i = 0; i < 512; ++i)
    {
      x[2*i] = y[2*(511-i)];
      x[2*i+1] = y[2*(511-i)];
    }
}

int
main ()
{   
  for (int i = 0; i < 1024; ++i)
    {
      x[i] = 0;
      y[i] = i;
      __asm__ volatile ("");
    }

  boo ();
  for (int i = 0; i < 1024; ++i)
    if (x[i] != y[2*(511 - i/2)])
      abort ();

  return 0;
}


segfaults because we emit

boo:
.LFB8:
        .cfi_startproc
        xorl    %eax, %eax
        .p2align 4,,10
        .p2align 3
.L21:
        movapd  y+8168(%rax), %xmm0
        movq    %rax, %rdx

where this is obviously misaligned.

Reply via email to