| 1 |
/* { dg-do run } */ |
| 2 |
/* { dg-options "-O -fdump-tree-ifcombine-details" } */ |
| 3 |
|
| 4 |
/* Check that we can optimize misaligned double-words. */ |
| 5 |
|
| 6 |
#include <stddef.h> |
| 7 |
|
| 8 |
struct s { |
| 9 |
short a; |
| 10 |
long long b; |
| 11 |
int c; |
| 12 |
long long d; |
| 13 |
short e; |
| 14 |
} __attribute__ ((packed, aligned (8))); |
| 15 |
|
| 16 |
struct s p = { 0, 0, 0, 0, 0 }; |
| 17 |
|
| 18 |
__attribute__ ((__noinline__, __noipa__, __noclone__)) |
| 19 |
int fp () |
| 20 |
{ |
| 21 |
if (p.a |
| 22 |
|| p.b |
| 23 |
|| p.c |
| 24 |
|| p.d |
| 25 |
|| p.e) |
| 26 |
return 1; |
| 27 |
else |
| 28 |
return -1; |
| 29 |
} |
| 30 |
|
| 31 |
int main () { |
| 32 |
/* Unlikely, but play safe. */ |
| 33 |
if (sizeof (long long) == sizeof (short)) |
| 34 |
return 0; |
| 35 |
if (fp () > 0) |
| 36 |
__builtin_abort (); |
| 37 |
unsigned char *pc = (unsigned char *)&p; |
| 38 |
for (int i = 0; i < offsetof (struct s, e) + sizeof (p.e); i++) |
| 39 |
{ |
| 40 |
pc[i] = 1; |
| 41 |
if (fp () < 0) |
| 42 |
__builtin_abort (); |
| 43 |
pc[i] = 0; |
| 44 |
} |
| 45 |
return 0; |
| 46 |
} |
| 47 |
|
| 48 |
/* { dg-final { scan-tree-dump-times "optimizing" 4 "ifcombine" { target { ! { avr-*-* pru-*-* } } } } } */ |