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

            Bug ID: 125296
           Summary: forwprop increases alignment requirements
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: kristerw at gcc dot gnu.org
            Blocks: 118443
  Target Milestone: ---

I believe the forwprop pass is incorrectly increasing alignment requirements
when the function below is compiled on x86_64 with -O2 -fno-strict-aliasing:

struct S {
  struct S *next;
  int vals[5];
};
int foo(struct S *s, int idx) {
  return *(volatile int *)&(s->vals[idx]);
}


The original GIMPLE for the function is:

int foo (struct S * s, int idx)
{
  int * _1;
  int _5;

  <bb 2> :
  _1 = &s_2(D)->vals[idx_3(D)];
  _5 ={v} MEM[(volatile int *)_1];
  return _5;
}

GIMPLE only requires correct alignment for the memory access, so I believe this
only requires s to be 32-bit aligned.

The forwprop pass modifies it in a way that requires 64-bit alignment:

int foo (struct S * s, int idx)
{
  int _5;

  <bb 2> :
  _5 ={v} MEM <struct S> [(volatile int *)s_2(D)].vals[idx_3(D)];
  return _5;
}


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