2013-05-06 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gcc.dg / simulate-thread / speculative-store-4.c
blob59f81b756be5c2c7ff21854c805af1a66e504ba3
1 /* { dg-do link } */
2 /* { dg-options "--param allow-store-data-races=0" } */
3 /* { dg-final { simulate-thread } } */
5 #include <stdio.h>
6 #include <stdlib.h>
8 #include "simulate-thread.h"
10 /* PR 54139 */
11 /* Test that speculative stores do not happen for --param
12 allow-store-data-races=0. */
14 int g_13=1, insns=1;
16 __attribute__((noinline))
17 void simulate_thread_main()
19 int l_245;
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)
28 int main()
30 simulate_thread_main ();
31 simulate_thread_done ();
32 return 0;
35 void simulate_thread_other_threads ()
37 ++g_13;
38 ++insns;
41 int simulate_thread_step_verify ()
43 return 0;
46 int simulate_thread_final_verify ()
48 if (g_13 != insns)
50 printf("FAIL: g_13 was incorrectly cached\n");
51 return 1;
53 return 0;