| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-options "-fgnu-tm -O3 -fdump-tree-tmmark" } */ |
| 3 |
/* Like memopt-12.c but the phi is inside a look which causes |
| 4 |
it to be converted into a COND_EXPR. */ |
| 5 |
|
| 6 |
extern int test(void) __attribute__((transaction_safe)); |
| 7 |
extern int something(void); |
| 8 |
extern void *malloc (__SIZE_TYPE__) __attribute__((malloc,transaction_safe)); |
| 9 |
|
| 10 |
struct large { int foo[500]; }; |
| 11 |
|
| 12 |
int f(int j) |
| 13 |
{ |
| 14 |
int *p1, *p2, *p3; |
| 15 |
|
| 16 |
p1 = malloc (sizeof (*p1)*5000); |
| 17 |
__transaction_atomic { |
| 18 |
_Bool t; |
| 19 |
int i = 1; |
| 20 |
*p1 = 0; |
| 21 |
|
| 22 |
p2 = malloc (sizeof (*p2)*6000); |
| 23 |
*p2 = 1; |
| 24 |
t = test(); |
| 25 |
|
| 26 |
for (i = 0;i < j;i++) |
| 27 |
{ |
| 28 |
|
| 29 |
/* p3 = PHI (p1, p2) */ |
| 30 |
if (t) |
| 31 |
p3 = p1; |
| 32 |
else |
| 33 |
p3 = p2; |
| 34 |
|
| 35 |
/* Since both p1 and p2 are thread-private, we can inherit the |
| 36 |
logging already done. No ITM_W* instrumentation necessary. */ |
| 37 |
*p3 = 555; |
| 38 |
} |
| 39 |
} |
| 40 |
return p3[something()]; |
| 41 |
} |
| 42 |
|
| 43 |
/* { dg-final { scan-tree-dump-times "ITM_WU" 0 "tmmark" } } */ |