]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/testsuite/gcc.dg/tm/memopt-12.c
Merge from transactional-memory branch.
[thirdparty/gcc.git] / gcc / testsuite / gcc.dg / tm / memopt-12.c
1 /* { dg-do compile } */
2 /* { dg-options "-fgnu-tm -O -fdump-tree-tmmark" } */
3
4 extern int test(void) __attribute__((transaction_safe));
5 extern void *malloc (__SIZE_TYPE__) __attribute__((malloc,transaction_safe));
6
7 struct large { int foo[500]; };
8
9 int f()
10 {
11 int *p1, *p2, *p3;
12
13 p1 = malloc (sizeof (*p1)*5000);
14 __transaction_atomic {
15 *p1 = 0;
16
17 p2 = malloc (sizeof (*p2)*6000);
18 *p2 = 1;
19
20 /* p3 = PHI (p1, p2) */
21 if (test())
22 p3 = p1;
23 else
24 p3 = p2;
25
26 /* Since both p1 and p2 are thread-private, we can inherit the
27 logging already done. No ITM_W* instrumentation necessary. */
28 *p3 = 555;
29 }
30 return p3[something()];
31 }
32
33 /* { dg-final { scan-tree-dump-times "ITM_WU" 0 "tmmark" } } */
34 /* { dg-final { cleanup-tree-dump "tmmark" } } */