aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gcc.dg/tm/pub-safety-1.c
blob: 660e9a6276730bd60cd3ba2e472aa39b79daaa8c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/* { dg-do compile } */
/* { dg-options "-fgnu-tm -O1 -fdump-tree-lim1" } */

/* Test that thread visible loads do not get hoisted out of loops if
   the load would not have occurred on each path out of the loop.  */

int x[10] = {0,0,0,0,0,0,0,0,0,0};
int DATA_DATA = 0;

void reader()
{
  int i;
  __transaction_atomic
    { 
      for (i = 0; i < 10; i++)
        if (x[i])
          x[i] += DATA_DATA;
      /* If we loaded DATA_DATA here, we could hoist it before the loop,
	 but since we don't... we can't.  */
    }
}

/* { dg-final { scan-tree-dump-times "Cannot hoist.*DATA_DATA because it is in a transaction" 1 "lim1" } } */
/* { dg-final { cleanup-tree-dump "lim1" } } */