[testsuite] require sqrt_insn effective target where needed
[official-gcc.git] / gcc / testsuite / gcc.target / powerpc / vsx-vector-1.c
blob364406ae7252b6fa2890be013f2de1b680162f3c
1 /* { dg-do compile } */
2 /* { dg-skip-if "" { powerpc*-*-darwin* } } */
3 /* { dg-require-effective-target powerpc_vsx_ok } */
4 /* { dg-options "-O2 -ftree-vectorize -mdejagnu-cpu=power7 -ffast-math" } */
5 /* { dg-final { scan-assembler "xvadddp" } } */
6 /* { dg-final { scan-assembler "xvsubdp" } } */
7 /* { dg-final { scan-assembler "xvmuldp" } } */
8 /* { dg-final { scan-assembler "xvdivdp" } } */
9 /* { dg-final { scan-assembler "xvmadd" } } */
10 /* { dg-final { scan-assembler "xvmsub" } } */
11 /* { dg-final { scan-assembler "xvsqrtdp" } } */
12 /* { dg-final { scan-assembler "xvcpsgndp" } } */
13 /* { dg-final { scan-assembler "xvrdpim" } } */
14 /* { dg-final { scan-assembler "xvrdpip" } } */
15 /* { dg-final { scan-assembler "xvrdpiz" } } */
16 /* { dg-final { scan-assembler "xvrdpic" } } */
17 /* { dg-final { scan-assembler "xvrdpi " } } */
19 #ifndef SIZE
20 #define SIZE 1024
21 #endif
23 double a[SIZE] __attribute__((__aligned__(32)));
24 double b[SIZE] __attribute__((__aligned__(32)));
25 double c[SIZE] __attribute__((__aligned__(32)));
26 double d[SIZE] __attribute__((__aligned__(32)));
27 double e[SIZE] __attribute__((__aligned__(32)));
29 void
30 vector_add (void)
32 int i;
34 for (i = 0; i < SIZE; i++)
35 a[i] = b[i] + c[i];
38 void
39 vector_subtract (void)
41 int i;
43 for (i = 0; i < SIZE; i++)
44 a[i] = b[i] - c[i];
47 void
48 vector_multiply (void)
50 int i;
52 for (i = 0; i < SIZE; i++)
53 a[i] = b[i] * c[i];
56 void
57 vector_multiply_add (void)
59 int i;
61 for (i = 0; i < SIZE; i++)
62 a[i] = (b[i] * c[i]) + d[i];
65 void
66 vector_multiply_subtract (void)
68 int i;
70 for (i = 0; i < SIZE; i++)
71 a[i] = (b[i] * c[i]) - d[i];
74 void
75 vector_divide (void)
77 int i;
79 for (i = 0; i < SIZE; i++)
80 a[i] = b[i] / c[i];
83 extern double sqrt (double);
84 extern double floor (double);
85 extern double ceil (double);
86 extern double trunc (double);
87 extern double nearbyint (double);
88 extern double rint (double);
89 extern double copysign (double, double);
91 void
92 vector_sqrt (void)
94 int i;
96 for (i = 0; i < SIZE; i++)
97 a[i] = sqrt (b[i]);
100 void
101 vector_floor (void)
103 int i;
105 for (i = 0; i < SIZE; i++)
106 a[i] = floor (b[i]);
109 void
110 vector_ceil (void)
112 int i;
114 for (i = 0; i < SIZE; i++)
115 a[i] = ceil (b[i]);
118 void
119 vector_trunc (void)
121 int i;
123 for (i = 0; i < SIZE; i++)
124 a[i] = trunc (b[i]);
127 void
128 vector_nearbyint (void)
130 int i;
132 for (i = 0; i < SIZE; i++)
133 a[i] = nearbyint (b[i]);
136 void
137 vector_rint (void)
139 int i;
141 for (i = 0; i < SIZE; i++)
142 a[i] = rint (b[i]);
145 void
146 vector_copysign (void)
148 int i;
150 for (i = 0; i < SIZE; i++)
151 a[i] = copysign (b[i], c[i]);