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

--- Comment #13 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Martin Jambor from comment #4)
> Created attachment 31402 [details]
> Patch detaching arrays away from aggregates
> 
> Eric, to what extent would this patch suffice?  

I think this patch should be done independently from Eric's improvement because
it can help non-nested case case like:
```
/* { dg-do compile } */
/* { dg-options "-O -fdump-tree-optimized" } */

struct S
{
  int a,b,c,d;
};

struct s1
{
  int a, b, c, d, i;
  int arr[16];
};

static
  int do_eval (struct s1 *a)
  {
    int acc = 0;
    for (a->i = 0; a->i < 16; a->i++)
      acc += a->arr[a->i];
    return a->a + a->b + a->c + a->d + acc;
  }

int eval (struct S s)
{
  struct s1 FRAME;
  FRAME.a = s.a;
  FRAME.b = s.b;
  FRAME.c = s.c;
  FRAME.d = s.d;


  for (FRAME. i = 0; FRAME. i < 16; FRAME. i++)
    FRAME.arr[FRAME. i] = FRAME. i;

  return do_eval (&FRAME);
}

/* { dg-final { scan-tree-dump-not "FRAME" "optimized" } } */
/* { dg-final { cleanup-tree-dump "optimized" } } */
```

Which might show up in C++.

Reply via email to