OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [testsuite/] [gcc.dg/] [matrix/] [matrix-3.c] - Blame information for rev 300

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 298 jeremybenn
/* { dg-do compile } */
2
/* { dg-options "-O3 -fipa-matrix-reorg -fdump-ipa-matrix-reorg -c -fwhole-program -combine"  } */
3
 
4
 
5
#include <stdio.h>
6
#include <stdlib.h>
7
#include <math.h>
8
#include <string.h>
9
 
10
void mem_init (void);
11
int ARCHnodes, ARCHnodes1;
12
int ***vel;
13
void just_a_call (int *);
14
 
15
/* The last dimension of VEL escapes because it was sent
16
   as argumet to just_a_call(). (external function)
17
   Only the two external dimensions are flattened.
18
   Run with -c.  */
19
 
20
 
21
/*--------------------------------------------------------------------------*/
22
 
23
int
24
main (int argc, char **argv)
25
{
26
  int i, j, k;
27
 
28
  ARCHnodes = 2;
29
  ARCHnodes1 = 4;
30
 
31
/* Dynamic memory allocations and initializations */
32
 
33
  mem_init ();
34
 
35
  for (i = 0; i < ARCHnodes; i++)
36
    {
37
      for (j = 0; j < 3; j++)
38
        {
39
          for (k = 0; k < ARCHnodes1; k++)
40
            printf ("[%d][%d][%d]=%d ", i, j, k, vel[i][j][k]);
41
          printf ("\n");
42
        }
43
      printf ("\n");
44
    }
45
  for (i = 0; i < ARCHnodes; i++)
46
    for (j = 0; j < 3; j++)
47
      free (vel[i][j]);
48
 
49
  for (i = 0; i < ARCHnodes; i++)
50
    free (vel[i]);
51
 
52
  free (vel);
53
  return 0;
54
}
55
 
56
/*--------------------------------------------------------------------------*/
57
/* Dynamic memory allocations and initializations                           */
58
 
59
void
60
mem_init (void)
61
{
62
 
63
  int i, j, k,d;
64
 
65
  d = 0;
66
  vel = (int ***) malloc (ARCHnodes * sizeof (int **));
67
 
68
  for (i = 0; i < ARCHnodes; i++)
69
    {
70
      vel[i] = (int **) malloc (3 * sizeof (int *));
71
      if (vel[i] == (int **) NULL)
72
        {
73
          fprintf (stderr, "malloc failed for vel[%d]\n", i);
74
          fflush (stderr);
75
          exit (0);
76
        }
77
    }
78
  for (i = 0; i < ARCHnodes; i++)
79
    {
80
      for (j = 0; j < 3; j++)
81
        {
82
          vel[i][j] = (int *) malloc (ARCHnodes1 * sizeof (int));
83
        }
84
    }
85
  for (i = 0; i < ARCHnodes; i++)
86
    {
87
      for (j = 0; j < 3; j++)
88
        {
89
          for (k = 0; k < ARCHnodes1; k++)
90
            {
91
              vel[i][j][k] = d;
92
              d++;
93
            }
94
        }
95
    }
96
  just_a_call (vel[1][1]);
97
}
98
 
99
/*--------------------------------------------------------------------------*/
100
/* { dg-final { scan-ipa-dump-times "Flattened 2 dimensions" 1 "matrix-reorg"  } } */
101
/* { dg-final { cleanup-ipa-dump "matrix-reorg" } } */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.