| 1 |
/* { dg-do compile } */ |
| 2 |
/* Disable FRE1 because that for the sake of __builtin_object_size |
| 3 |
will not consider the equality but still valueize 'i', defeating |
| 4 |
the purpose of the check. */ |
| 5 |
/* { dg-options "-O -fdump-tree-fre3 -fdisable-tree-fre1" } */ |
| 6 |
|
| 7 |
struct S { int a[4]; }; |
| 8 |
|
| 9 |
int i; |
| 10 |
int bar (struct S *p) |
| 11 |
{ |
| 12 |
char *q = (char *)p + 4; |
| 13 |
i = 1; |
| 14 |
int *r = &((struct S *)p)->a[i]; |
| 15 |
return q == (char *)r; |
| 16 |
} |
| 17 |
int baz (struct S *p) |
| 18 |
{ |
| 19 |
i = 1; |
| 20 |
int *r = &((struct S *)p)->a[i]; |
| 21 |
char *q = (char *)p + 4; |
| 22 |
return q == (char *)r; |
| 23 |
} |
| 24 |
|
| 25 |
/* Verify FRE can handle valueizing &p->a[i] and value-numbering it |
| 26 |
equal to a POINTER_PLUS_EXPR. */ |
| 27 |
/* { dg-final { scan-tree-dump-times "return 1;" 2 "fre3" } } */ |