c++: normalizing ttp constraints [PR115656]
[official-gcc.git] / gcc / testsuite / gcc.target / powerpc / htm-1.c
blob399a7ec881238eb99b2ef32fe46e3b039343306a
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;
15 unsigned long retry_count = 0;
17 repeat:
18 if (__builtin_tbegin (0))
20 mask++;
21 retry_count = 0;
23 else
25 /* Retry a limited number of times before aborting. */
26 if (retry_count++ < 10)
27 goto repeat;
28 abort ();
31 if (mask == 1)
33 __builtin_tsuspend ();
35 if (_HTM_STATE (__builtin_tcheck ()) != _HTM_SUSPENDED)
36 abort ();
38 __builtin_tresume ();
40 if (_HTM_STATE (__builtin_tcheck ()) != _HTM_TRANSACTIONAL)
41 abort ();
43 else
44 mask++;
46 if (_HTM_STATE (__builtin_tendall ()) != _HTM_TRANSACTIONAL)
47 abort ();
49 if (mask == 1)
50 goto repeat;
52 if (_HTM_STATE (__builtin_tendall ()) != _HTM_NONTRANSACTIONAL)
53 abort ();
55 if (mask != 3)
56 abort ();
58 return 0;