1 /* { dg-do run } */
2 /* { dg-options "-O2 -funswitch-loops" } */
3
4 #include <stdlib.h>
5 __attribute__ ((noinline))
foo(float ** a,float ** b,float * c,int n,int m,int l)6 void foo (float **a, float **b, float *c, int n, int m, int l)
7 {
8 int i,j,k;
9 float s;
10 for (i=0; i<l; i++)
11 for (j=0; j<n; j++)
12 for (k=0; k<m; k++)
13 c[i] += a[i][k] * b[k][j];
14 }
15
main()16 int main()
17 {
18 const int N = 32;
19 float **ar1, **ar2;
20 float *res;
21 int i, j;
22 ar1 = (float **)malloc (N * sizeof (float*));
23 ar2 = (float **)malloc (N * sizeof (float*));
24 res = (float *)malloc( N * sizeof (float));
25 for (i=0; i<N; i++)
26 {
27 ar1[i] = (float*)malloc (N * sizeof (float));
28 ar2[i] = (float*)malloc (N * sizeof (float));
29 }
30 for (i=0; i<N; i++)
31 {
32 for (j=0; j<N; j++)
33 {
34 ar1[i][j] = 2.0f;
35 ar2[i][j] = 1.5f;
36 }
37 res[i] = 0.0f;
38 }
39 foo (ar1, ar2, res, N, N, N);
40 for (i=0; i<N; i++)
41 if (res[i] != 3072.0f)
42 abort();
43 for (i=0; i<N; i++)
44 res[i] = 0.0f;
45 foo (ar1, ar2, res, N, 0, N);
46 for (i=0; i<N; i++)
47 if (res[i] != 0.0f)
48 abort();
49
50 return 0;
51 }
52
53