Small ChangeLog tweak.
[official-gcc.git] / gcc / testsuite / gcc.dg / torture / transpose-3.c
blob8b55a2efbcd5bace9cf2656db4ed6debc9c8cd35
1 /* { dg-do run } */
2 /* { dg-options "-fwhole-program" } */
4 #include <stdio.h>
5 #include <stdlib.h>
6 #include <math.h>
7 #include <string.h>
9 void mem_init (void);
10 int ARCHnodes, ARCHnodes1;
11 int ***vel;
12 /* The inner most dimension escapes.
13 The two external dimensions are flattened
14 after being transposed. */
15 /*--------------------------------------------------------------------------*/
17 int
18 main (int argc, char **argv)
20 int i, j, k;
22 ARCHnodes = 2;
23 ARCHnodes1 = 4;
25 /* Dynamic memory allocations and initializations */
27 mem_init ();
29 for (j = 0; j < 4; j++)
31 for (i = 0; i < 3; i++)
33 for (k = 0; k < 2; k++)
35 printf ("[%d][%d][%d]=%d ", i, j, k, vel[k][i][j]);
37 printf ("\n");
39 printf ("\n");
41 vel[0][0]=vel[1][1];
43 for (i = 0; i < 2; i++)
44 for (j = 0; j < 3; j++)
45 if (i==1 && j==1)
46 continue;
47 else
48 free (vel[i][j]);
50 for (i = 0; i < 2; i++)
51 free (vel[i]);
53 free (vel);
54 return 0;
57 /*--------------------------------------------------------------------------*/
58 /* Dynamic memory allocations and initializations */
60 void
61 mem_init (void)
64 signed int i, j, k,d;
66 d = 0;
67 vel = (int ***) malloc (ARCHnodes * sizeof (int **));
69 for (i = 0; i < ARCHnodes; i++)
71 vel[i] = (int **) malloc (3 * sizeof (int *));
72 if (vel[i] == (int **) NULL)
74 printf ("malloc failed for vel[%d]\n", i);
75 exit (0);
78 for (i = 0; i < ARCHnodes; i++)
80 for (j = 0; j < 3; j++)
82 vel[i][j] = (int *) malloc (ARCHnodes1 * sizeof (int));
85 for (i = 0; i < ARCHnodes; i++)
87 for (j = 0; j < 3; j++)
89 for (k = 0; k < ARCHnodes1; k++)
91 printf ("acc to dim2 ");
92 vel[i][j][k] = d;
93 d++;
97 printf ("\n");
100 /*--------------------------------------------------------------------------*/