1 /* { dg-do compile } */
2 /* { dg-options "-O2" } */
4 /* Check volatiles are written, read or not re-read consistently */
7 /* simple assignments */
9 extern int volatile obj_0;
10 void test_0 (int data)
12 /* should not reread obj */
13 /* { dg-final { scan-assembler "movl\[ \t\]\[^,\]+, obj_0(\\(%rip\\))?" } } */
14 /* { dg-final { scan-assembler-not "movl\[ \t\]obj_0(\\(%rip\\))?," } } */
18 extern int volatile obj_1;
21 /* should not reread obj */
22 /* { dg-final { scan-assembler "movl\[ \t\]\[^,\]+, obj_1(\\(%rip\\))?" } } */
23 /* { dg-final { scan-assembler-not "movl\[ \t\]obj_1(\\(%rip\\))?," } } */
27 extern int volatile obj_2;
30 /* should not reread obj */
31 /* { dg-final { scan-assembler "movl\[ \t\]\[^,\]+, obj_2(\\(%rip\\))?" } } */
32 /* { dg-final { scan-assembler-not "movl\[ \t\]obj_2(\\(%rip\\))?," } } */
37 /* Assignments in compound exprs */
39 extern int volatile obj_3;
42 /* should not reread obj */
43 /* { dg-final { scan-assembler "movl\[ \t\]\[^,\]+, obj_3(\\(%rip\\))?" } } */
44 /* { dg-final { scan-assembler-not "movl\[ \t\]obj_3(\\(%rip\\))?," } } */
45 return (obj_3 = data, 0);
48 extern int volatile obj_4;
51 /* should not reread obj */
52 /* { dg-final { scan-assembler "movl\[ \t\]\[^,\]+, obj_4(\\(%rip\\))?" } } */
53 /* { dg-final { scan-assembler-not "movl\[ \t\]obj_4(\\(%rip\\))?," } } */
54 return (obj_4 = 0, 0);
56 extern int volatile obj_5;
59 /* should reread obj */
60 /* { dg-final { scan-assembler "movl\[ \t\]\[^,\]+, obj_5(\\(%rip\\))?" } } */
61 /* { dg-final { scan-assembler "movl\[ \t\]obj_5(\\(%rip\\))?," } } */
62 return (obj_5 = 0, obj_5);
65 /* Assignments in conditional exprs */
67 extern int volatile obj_6;
68 void test_6 (int data, int cond)
70 /* should not reread obj */
71 /* { dg-final { scan-assembler "movl\[ \t\]\[^,\]+, obj_6(\\(%rip\\))?" } } */
72 /* { dg-final { scan-assembler-not "movl\[ \t\]obj_6(\\(%rip\\))?," } } */
73 cond ? obj_6 = data : 0;
76 extern int volatile obj_7;
77 int test_7 (int data, int cond)
79 /* should not reread obj */
80 /* { dg-final { scan-assembler "movl\[ \t\]\[^,\]+, obj_7(\\(%rip\\))?" } } */
81 /* { dg-final { scan-assembler-not "movl\[ \t\]obj_7(\\(%rip\\))?," } } */
82 return cond ? obj_7 = data : 0;
85 extern int volatile obj_8;
88 /* should not reread obj */
89 /* { dg-final { scan-assembler "movl\[ \t\]\[^,\]+, obj_8(\\(%rip\\))?" } } */
90 /* { dg-final { scan-assembler-not "movl\[ \t\]obj_8(\\(%rip\\))?," } } */
91 return cond ? obj_8 = 0 : 0;