Imported Upstream version 4.7.3
[platform/upstream/gcc48.git] / gcc / testsuite / gcc.dg / vect / fast-math-vect-call-2.c
1 /* { dg-require-effective-target vect_double } */
2
3 #include "tree-vect.h"
4
5 extern long int lrint (double);
6 extern void abort (void);
7 long int a[64];
8 double b[64];
9
10 __attribute__((noinline, noclone)) void
11 f1 (int n)
12 {
13   int i;
14   for (i = 0; i < n; i++)
15     {
16       a[4 * i + 0] = lrint (b[4 * i + 0]) + 1;
17       a[4 * i + 1] = lrint (b[4 * i + 1]) + 2;
18       a[4 * i + 2] = lrint (b[4 * i + 2]) + 3;
19       a[4 * i + 3] = lrint (b[4 * i + 3]) + 4;
20     }
21 }
22
23 __attribute__((noinline, noclone)) void
24 f2 (int n)
25 {
26   int i;
27   for (i = 0; i < 2 * n; i++)
28     {
29       a[2 * i + 0] = lrint (b[2 * i + 0]) + 1;
30       a[2 * i + 1] = lrint (b[2 * i + 1]) + 2;
31     }
32 }
33
34 __attribute__((noinline, noclone)) void
35 f3 (void)
36 {
37   int i;
38   for (i = 0; i < 64; i++)
39     a[i] = lrint (b[i]) + 1;
40 }
41
42 __attribute__((noinline, noclone)) void
43 f4 (int n)
44 {
45   int i;
46   for (i = 0; i < n; i++)
47     {
48       a[4 * i + 0] = lrint (b[4 * i + 0]);
49       a[4 * i + 1] = lrint (b[4 * i + 1]);
50       a[4 * i + 2] = lrint (b[4 * i + 2]);
51       a[4 * i + 3] = lrint (b[4 * i + 3]);
52     }
53 }
54
55 __attribute__((noinline, noclone)) void
56 f5 (int n)
57 {
58   int i;
59   for (i = 0; i < 2 * n; i++)
60     {
61       a[2 * i + 0] = lrint (b[2 * i + 0]);
62       a[2 * i + 1] = lrint (b[2 * i + 1]);
63     }
64 }
65
66 __attribute__((noinline, noclone)) void
67 f6 (void)
68 {
69   int i;
70   for (i = 0; i < 64; i++)
71     a[i] = lrint (b[i]);
72 }
73
74 __attribute__((noinline, noclone)) int
75 main1 ()
76 {
77   int i;
78
79   for (i = 0; i < 64; i++)
80     {
81       asm ("");
82       b[i] = ((i & 1) ? -4 * i : 4 * i) + 0.25;
83     }
84   f1 (16);
85   for (i = 0; i < 64; i++)
86     if (a[i] != ((i & 1) ? -4 * i : 4 * i) + 1 + (i & 3))
87       abort ();
88     else
89       a[i] = 131.25;
90   f2 (16);
91   for (i = 0; i < 64; i++)
92     if (a[i] != ((i & 1) ? -4 * i : 4 * i) + 1 + (i & 1))
93       abort ();
94     else
95       a[i] = 131.25;
96   f3 ();
97   for (i = 0; i < 64; i++)
98     if (a[i] != ((i & 1) ? -4 * i : 4 * i) + 1)
99       abort ();
100     else
101       a[i] = 131.25;
102   f4 (16);
103   for (i = 0; i < 64; i++)
104     if (a[i] != ((i & 1) ? -4 * i : 4 * i))
105       abort ();
106     else
107       a[i] = 131.25;
108   f5 (16);
109   for (i = 0; i < 64; i++)
110     if (a[i] != ((i & 1) ? -4 * i : 4 * i))
111       abort ();
112     else
113       a[i] = 131.25;
114   f6 ();
115   for (i = 0; i < 64; i++)
116     if (a[i] != ((i & 1) ? -4 * i : 4 * i))
117       abort ();
118   return 0;
119 }
120
121 int
122 main ()
123 {
124   check_vect ();
125   return main1 ();
126 }
127
128 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 6 "vect" { target vect_call_lrint } } } */
129 /* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 4 "vect" { target vect_call_lrint } } } */
130 /* { dg-final { cleanup-tree-dump "vect" } } */