| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-require-effective-target size32plus } */ |
| 3 |
/* { dg-options "-fstrict-volatile-bitfields -fdump-rtl-final" } */ |
| 4 |
|
| 5 |
/* With -fstrict-volatile-bitfields, the volatile accesses to bf2.b |
| 6 |
and bf3.b must do unsigned int reads/writes. The non-volatile |
| 7 |
accesses to bf1.b are not so constrained. */ |
| 8 |
|
| 9 |
extern struct |
| 10 |
{ |
| 11 |
unsigned int b : 1; |
| 12 |
unsigned int : 31; |
| 13 |
} __attribute__((aligned(4))) bf1; |
| 14 |
|
| 15 |
extern volatile struct |
| 16 |
{ |
| 17 |
unsigned int b : 1; |
| 18 |
unsigned int : 31; |
| 19 |
} __attribute__((aligned(4))) bf2; |
| 20 |
|
| 21 |
extern struct |
| 22 |
{ |
| 23 |
volatile unsigned int b : 1; |
| 24 |
volatile unsigned int : 31; |
| 25 |
} __attribute__((aligned(4))) bf3; |
| 26 |
|
| 27 |
void writeb(void) |
| 28 |
{ |
| 29 |
bf1.b = 1; |
| 30 |
bf2.b = 1; /* volatile read + volatile write */ |
| 31 |
bf3.b = 1; /* volatile read + volatile write */ |
| 32 |
} |
| 33 |
|
| 34 |
extern unsigned int x1, x2, x3; |
| 35 |
|
| 36 |
void readb(void) |
| 37 |
{ |
| 38 |
x1 = bf1.b; |
| 39 |
x2 = bf2.b; /* volatile write */ |
| 40 |
x3 = bf3.b; /* volatile write */ |
| 41 |
} |
| 42 |
|
| 43 |
/* There should be 6 volatile MEMs total, but scan-rtl-dump-times counts |
| 44 |
the number of match variables and not the number of matches. Since |
| 45 |
the parenthesized subexpression in the regexp introduces an extra match |
| 46 |
variable, we need to give a count of 12 instead of 6 here. */ |
| 47 |
/* { dg-final { scan-rtl-dump-times "mem/v(/.)*:SI" 12 "final" } } */ |