2 /* { dg-options "--param allow-store-data-races=0 -O2" } */
3 /* { dg-final { simulate-thread } } */
8 #include "simulate-thread.h"
10 /* Test distilled from PR52558. */
13 int g_2 = 0, insns = 0;
16 /* Test that g_2 is not written to unless !g_1. */
18 __attribute__((noinline))
22 for (l = 0; l != 4; l++)
26 /* g_1 is globally true so we should always execute here,
27 thus never writing to g_2 under any circumstance in this
31 for (g_2 = 0; g_2 >= 26; ++g_2)
37 int simulate_thread_final_verify ()
39 /* If g_2 != insns, someone must have cached `g_2' and stored a
40 racy value into it. */
43 printf("FAIL: g_2 was incorrectly cached\n");
49 void simulate_thread_other_threads ()
55 int simulate_thread_step_verify ()
60 __attribute__((noinline))
61 void simulate_thread_main()
68 simulate_thread_main ();
69 simulate_thread_done ();