| 1 |
/* { dg-options "-mthumb -Os -fpic -fdump-rtl-hoist" } */ |
| 2 |
/* { dg-require-effective-target arm_thumb1_ok } */ |
| 3 |
/* { dg-require-effective-target fpic } */ |
| 4 |
/* Make sure all calculations of gObj's address get hoisted to one location. */ |
| 5 |
/* { dg-final { scan-rtl-dump "PRE/HOIST: end of bb .* copying expression" "hoist" } } */ |
| 6 |
|
| 7 |
struct st_a { |
| 8 |
int data; |
| 9 |
}; |
| 10 |
|
| 11 |
struct st_b { |
| 12 |
struct st_a *p_a; |
| 13 |
struct st_b *next; |
| 14 |
}; |
| 15 |
|
| 16 |
extern struct st_b gObj; |
| 17 |
extern void foo(int, struct st_b*); |
| 18 |
|
| 19 |
int goo(struct st_b * obj) { |
| 20 |
struct st_a *pa; |
| 21 |
if (gObj.p_a->data != 0) { |
| 22 |
foo(gObj.p_a->data, obj); |
| 23 |
} |
| 24 |
pa = obj->p_a; |
| 25 |
if (pa == 0) { |
| 26 |
return 0; |
| 27 |
} else if (pa == gObj.p_a) { |
| 28 |
return 0; |
| 29 |
} |
| 30 |
return pa->data; |
| 31 |
} |