Merge branches/gcc-4_9-branch rev 225109.
[official-gcc.git] / gcc-4_9-branch / gcc / testsuite / gcc.target / powerpc / htm-1.c
blobf27e32ca281a074c1c0080840c970a0353a2952e
1 /* { dg-do run { target { powerpc*-*-* && htm_hw } } } */
2 /* { dg-require-effective-target powerpc_htm_ok } */
3 /* { dg-options "-mhtm" } */
5 /* Program to test PowerPC HTM instructions. */
7 #include <stdlib.h>
8 #include <htmintrin.h>
10 int
11 main (void)
13 long i;
14 unsigned long mask = 0;
16 repeat:
17 if (__builtin_tbegin (0))
19 mask++;
21 else
22 abort();
24 if (mask == 1)
26 __builtin_tsuspend ();
28 if (_HTM_STATE (__builtin_tcheck ()) != _HTM_SUSPENDED)
29 abort ();
31 __builtin_tresume ();
33 if (_HTM_STATE (__builtin_tcheck ()) != _HTM_TRANSACTIONAL)
34 abort ();
36 else
37 mask++;
39 if (_HTM_STATE (__builtin_tendall ()) != _HTM_TRANSACTIONAL)
40 abort ();
42 if (mask == 1)
43 goto repeat;
45 if (_HTM_STATE (__builtin_tendall ()) != _HTM_NONTRANSACTIONAL)
46 abort ();
48 if (mask != 3)
49 abort ();
51 return 0;