Imported Upstream version 4.8.1
[platform/upstream/gcc48.git] / gcc / testsuite / gcc.dg / simulate-thread / speculative-store-4.c
1 /* { dg-do link } */
2 /* { dg-options "--param allow-store-data-races=0" } */
3 /* { dg-final { simulate-thread } } */
4
5 #include <stdio.h>
6 #include <stdlib.h>
7
8 #include "simulate-thread.h"
9
10 /* PR 54139 */
11 /* Test that speculative stores do not happen for --param
12    allow-store-data-races=0.  */
13
14 int g_13=1, insns=1;
15
16 __attribute__((noinline))
17 void simulate_thread_main()
18 {
19   int l_245;
20
21   /* Since g_13 is unilaterally set positive above, there should be
22      no store to g_13 below.  */
23   for (l_245 = 0; l_245 <= 1; l_245 += 1)
24     for (; g_13 <= 0; g_13 = 1)
25       ;
26 }
27
28 int main()
29 {
30   simulate_thread_main ();
31   simulate_thread_done ();
32   return 0;
33 }
34
35 void simulate_thread_other_threads ()
36 {
37   ++g_13;
38   ++insns;
39 }
40
41 int simulate_thread_step_verify ()
42 {
43   return 0;
44 }
45
46 int simulate_thread_final_verify ()
47 {
48   if (g_13 != insns)
49     {
50       printf("FAIL: g_13 was incorrectly cached\n");
51       return 1;
52     }
53   return 0;
54 }