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

            Bug ID: 86024
           Summary: Missed memcpy loop distribution with elementwise copy
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: glisse at gcc dot gnu.org
  Target Milestone: ---

typedef struct A { int a, b; } A;
void*f(A*restrict p){
  A*q=__builtin_malloc(1024*sizeof(A));
  for(int i=0;i<1024;++i){
#ifdef HELP
    q[i]=p[i];
#else
    q[i].a=p[i].a;
    q[i].b=p[i].b;
#endif
  }
  return q;
}

At -O3, with HELP, we get the expected memcpy. Without it, the loop is only
vectorized.

Reply via email to