libcpp, c, middle-end: Optimize initializers using #embed in C
[official-gcc.git] / gcc / testsuite / gcc.dg / tm / memopt-12.c
blob321f6c09927641a0c0b52eefda26ab08718ee5ff
1 /* { dg-do compile } */
2 /* { dg-options "-fgnu-tm -O -fdump-tree-tmmark" } */
4 extern int test(void) __attribute__((transaction_safe));
5 extern int something (void);
6 extern void *malloc (__SIZE_TYPE__) __attribute__((malloc,transaction_safe));
8 struct large { int foo[500]; };
10 int f()
12 int *p1, *p2, *p3;
14 p1 = malloc (sizeof (*p1)*5000);
15 __transaction_atomic {
16 *p1 = 0;
18 p2 = malloc (sizeof (*p2)*6000);
19 *p2 = 1;
21 /* p3 = PHI (p1, p2) */
22 if (test())
23 p3 = p1;
24 else
25 p3 = p2;
27 /* Since both p1 and p2 are thread-private, we can inherit the
28 logging already done. No ITM_W* instrumentation necessary. */
29 *p3 = 555;
31 return p3[something()];
34 /* { dg-final { scan-tree-dump-times "ITM_WU" 0 "tmmark" } } */