2017-11-17 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gcc.dg / autopar / pr49960.c
blob447169d991ad94c32d428c9e4ede0d7793cb7a5c
1 /* { dg-do compile } */
2 /* { dg-options "-O2 -ftree-parallelize-loops=4 -fdump-tree-parloops2-details -fdump-tree-optimized -fno-partial-inlining" } */
4 #include <stdio.h>
5 #define MB 100
6 #define NA 450
7 #define MA 400
9 int T[MA][MB],A[MA][NA],B[MB][NA];
10 void __attribute__((noinline))
11 MRTRBR(int MA_1, int NA_1, int MB_1)
13 int i,j, t,k;
15 /* At the moment we are not able to hoist the loop headers out of the loop
16 nest.
17 Partial inlining needs to be disabled so we do not optimize this out
18 of the function body. */
19 if (MA_1 < 4 || NA_1 < 4 || MB_1 < 4)
20 return;
22 /* The outer most loop is not parallel because for different k's there
23 is write-write dependency for T[i][j]. */
25 /* The innermost loop doesn't get parallelized due to low number of
26 iterations. */
28 for (k = 3; k < NA_1; k++)
29 for (i = 3; i < MA_1; i++)
30 for (j = 3; j < MB_1; j++)
32 t = T[i][j];
33 T[i][j] = t+2+A[i][k]*B[j][k];
36 void main ()
38 int j,i;
40 for (i = 3; i < MA; i++)
41 for (j = 3; j < MB; j++)
43 __asm__ volatile ("" : : : "memory");
44 T[i][j] = (i>j?i:j);
47 MRTRBR (MA,NA,MB);
49 for (i = MA-1; i < MA; i++)
50 for (j = MB-10; j < MB; j++)
51 printf ("i %d j %d T[i][j] = %d\n",i,j,T[i][j]);
55 /* Check that the outer most loop doesn't get parallelized. */
57 /* { dg-final { scan-tree-dump-times "SUCCESS: may be parallelized" 1 "parloops2" } } */
58 /* { dg-final { scan-tree-dump-times "__builtin_GOMP_parallel" 1 "optimized" } } */