OSDN Git Service

Latest updates from FSF 4.7 branch
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / torture / pr53366-1.c
1 /* PR tree-optimization/53366 */
2 /* { dg-do run { target { int32plus } } } */
3
4 extern void abort (void);
5
6 struct S { double v[3]; };
7 struct T { struct S r, i; };
8 struct U { struct T j[5]; };
9
10 void
11 foo (struct U *__restrict p1, struct U *__restrict p2,
12      struct S l1, struct S l2, struct S l3, struct S l4,
13      const double _Complex * __restrict x, int y, int z)
14 {
15   int i, j;
16   while (y < z - 2)
17     {
18       for (j = 0; j < 5; ++j)
19         {
20           double a = __real__ x[5 * y + j];
21           double b = __imag__ x[5 * y + j];
22           double c = __real__ x[5 * (y + 2) + j];
23           double d = __imag__ x[5 * (y + 2) + j];
24           double e = __real__ x[5 * (y + 1) + j];
25           double f = __imag__ x[5 * (y + 1) + j];
26           double g = __real__ x[5 * (y + 3) + j];
27           double h = __imag__ x[5 * (y + 3) + j];
28           for (i = 0; i < 3; ++i)
29             {
30               p1->j[j].r.v[i] += l2.v[i] * a;
31               p1->j[j].r.v[i] += l4.v[i] * c;
32               p1->j[j].i.v[i] += l2.v[i] * b;
33               p1->j[j].i.v[i] += l4.v[i] * d;
34               p2->j[j].r.v[i] += l3.v[i] * e;
35               p2->j[j].r.v[i] += l1.v[i] * g;
36               p2->j[j].i.v[i] += l3.v[i] * f;
37               p2->j[j].i.v[i] += l1.v[i] * h;
38             }
39         }
40       y += 4;
41     }
42 }
43
44 _Complex double x[5005];
45 struct U p1, p2;
46
47 int
48 main ()
49 {
50   int i, j;
51   struct S l1, l2, l3, l4;
52   for (i = 0; i < 5005; ++i)
53     x[i] = i + 1.0iF * (2 * i);
54   for (i = 0; i < 3; ++i)
55     {
56       l1.v[i] = 1;
57       l2.v[i] = 2;
58       l3.v[i] = 3;
59       l4.v[i] = 4;
60     }
61   foo (&p1, &p2, l1, l2, l3, l4, x, 5, 1000);
62   for (j = 0; j < 5; ++j)
63     for (i = 0; i < 3; ++i)
64       if (p1.j[j].r.v[i] != 3752430 + j * 1494.0
65           || p1.j[j].i.v[i] != p1.j[j].r.v[i] * 2
66           || p2.j[j].r.v[i] != 2502450 + j * 996.0
67           || p2.j[j].i.v[i] != p2.j[j].r.v[i] * 2)
68         abort ();
69   return 0;
70 }