| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-options "-O -fdump-tree-fre1" } */ |
| 3 |
|
| 4 |
struct A { float x, y; }; |
| 5 |
struct B { struct A u; }; |
| 6 |
void bar (struct A *); |
| 7 |
|
| 8 |
float |
| 9 |
f1 (struct B *x, int y) |
| 10 |
{ |
| 11 |
struct A p; |
| 12 |
p.x = 1.0f; |
| 13 |
p.y = 2.0f; |
| 14 |
struct A *q = &x[y].u; |
| 15 |
*q = p; |
| 16 |
float f = x[y].u.x + x[y].u.y; |
| 17 |
bar (&p); |
| 18 |
return f; |
| 19 |
} |
| 20 |
|
| 21 |
float |
| 22 |
f2 (struct B *x, int y) |
| 23 |
{ |
| 24 |
struct A p; |
| 25 |
p.x = 1.0f; |
| 26 |
p.y = 2.0f; |
| 27 |
x[y].u = p; |
| 28 |
float f = x[y].u.x + x[y].u.y; |
| 29 |
bar (&p); |
| 30 |
return f; |
| 31 |
} |
| 32 |
|
| 33 |
float |
| 34 |
f3 (struct B *x, int y) |
| 35 |
{ |
| 36 |
struct A p; |
| 37 |
p.x = 1.0f; |
| 38 |
p.y = 2.0f; |
| 39 |
struct A *q = &x[y].u; |
| 40 |
__builtin_memcpy (&q->x, &p.x, sizeof (float)); |
| 41 |
__builtin_memcpy (&q->y, &p.y, sizeof (float)); |
| 42 |
float f = x[y].u.x + x[y].u.y; |
| 43 |
bar (&p); |
| 44 |
return f; |
| 45 |
} |
| 46 |
|
| 47 |
float |
| 48 |
f4 (struct B *x, int y) |
| 49 |
{ |
| 50 |
struct A p; |
| 51 |
p.x = 1.0f; |
| 52 |
p.y = 2.0f; |
| 53 |
__builtin_memcpy (&x[y].u.x, &p.x, sizeof (float)); |
| 54 |
__builtin_memcpy (&x[y].u.y, &p.y, sizeof (float)); |
| 55 |
float f = x[y].u.x + x[y].u.y; |
| 56 |
bar (&p); |
| 57 |
return f; |
| 58 |
} |
| 59 |
|
| 60 |
/* { dg-final { scan-tree-dump-times "return 3.0" 4 "fre1" } } */ |