1 /* { dg-do compile { target { powerpc*-*-* } } } */
2 /* { dg-skip-if "" { powerpc*-*-darwin* } } */
3 /* { dg-require-effective-target powerpc_vsx_ok } */
4 /* { dg-options "-O2 -mdejagnu-cpu=power7" } */
5
6 /* Check whether tdiv and tsqrt instructions generate the correct code. */
7 /* Each of the *tdiv* and *tsqrt* instructions should be generated exactly 3
8 times (the two calls in the _1 function should be combined). */
9 /* { dg-final { scan-assembler-times "xstdivdp" 3 } } */
10 /* { dg-final { scan-assembler-times "xvtdivdp" 3 } } */
11 /* { dg-final { scan-assembler-times "xvtdivsp" 3 } } */
12 /* { dg-final { scan-assembler-times "xstsqrtdp" 3 } } */
13 /* { dg-final { scan-assembler-times "xvtsqrtdp" 3 } } */
14 /* { dg-final { scan-assembler-times "xvtsqrtsp" 3 } } */
15
test_div_df_1(double a,double b,int * p)16 void test_div_df_1 (double a, double b, int *p)
17 {
18 p[0] = __builtin_vsx_xstdivdp_fe (a, b);
19 p[1] = __builtin_vsx_xstdivdp_fg (a, b);
20 }
21
test_div_df_2(double a,double b,int * p)22 int *test_div_df_2 (double a, double b, int *p)
23 {
24 if (__builtin_vsx_xstdivdp_fe (a, b))
25 *p++ = 1;
26
27 return p;
28 }
29
test_div_df_3(double a,double b,int * p)30 int *test_div_df_3 (double a, double b, int *p)
31 {
32 if (__builtin_vsx_xstdivdp_fg (a, b))
33 *p++ = 1;
34
35 return p;
36 }
37
test_sqrt_df_1(double a,int * p)38 void test_sqrt_df_1 (double a, int *p)
39 {
40 p[0] = __builtin_vsx_xstsqrtdp_fe (a);
41 p[1] = __builtin_vsx_xstsqrtdp_fg (a);
42 }
43
test_sqrt_df_2(double a,int * p)44 int *test_sqrt_df_2 (double a, int *p)
45 {
46 if (__builtin_vsx_xstsqrtdp_fe (a))
47 *p++ = 1;
48
49 return p;
50 }
51
test_sqrt_df_3(double a,int * p)52 int *test_sqrt_df_3 (double a, int *p)
53 {
54 if (__builtin_vsx_xstsqrtdp_fg (a))
55 *p++ = 1;
56
57 return p;
58 }
59
test_div_v2df_1(__vector double * a,__vector double * b,int * p)60 void test_div_v2df_1 (__vector double *a, __vector double *b, int *p)
61 {
62 p[0] = __builtin_vsx_xvtdivdp_fe (*a, *b);
63 p[1] = __builtin_vsx_xvtdivdp_fg (*a, *b);
64 }
65
test_div_v2df_2(__vector double * a,__vector double * b,int * p)66 int *test_div_v2df_2 (__vector double *a, __vector double *b, int *p)
67 {
68 if (__builtin_vsx_xvtdivdp_fe (*a, *b))
69 *p++ = 1;
70
71 return p;
72 }
73
test_div_v2df_3(__vector double * a,__vector double * b,int * p)74 int *test_div_v2df_3 (__vector double *a, __vector double *b, int *p)
75 {
76 if (__builtin_vsx_xvtdivdp_fg (*a, *b))
77 *p++ = 1;
78
79 return p;
80 }
81
test_sqrt_v2df_1(__vector double * a,int * p)82 void test_sqrt_v2df_1 (__vector double *a, int *p)
83 {
84 p[0] = __builtin_vsx_xvtsqrtdp_fe (*a);
85 p[1] = __builtin_vsx_xvtsqrtdp_fg (*a);
86 }
87
test_sqrt_v2df_2(__vector double * a,int * p)88 int *test_sqrt_v2df_2 (__vector double *a, int *p)
89 {
90 if (__builtin_vsx_xvtsqrtdp_fe (*a))
91 *p++ = 1;
92
93 return p;
94 }
95
test_sqrt_v2df_3(__vector double * a,int * p)96 int *test_sqrt_v2df_3 (__vector double *a, int *p)
97 {
98 if (__builtin_vsx_xvtsqrtdp_fg (*a))
99 *p++ = 1;
100
101 return p;
102 }
103
test_div_v4sf_1(__vector float * a,__vector float * b,int * p)104 void test_div_v4sf_1 (__vector float *a, __vector float *b, int *p)
105 {
106 p[0] = __builtin_vsx_xvtdivsp_fe (*a, *b);
107 p[1] = __builtin_vsx_xvtdivsp_fg (*a, *b);
108 }
109
test_div_v4sf_2(__vector float * a,__vector float * b,int * p)110 int *test_div_v4sf_2 (__vector float *a, __vector float *b, int *p)
111 {
112 if (__builtin_vsx_xvtdivsp_fe (*a, *b))
113 *p++ = 1;
114
115 return p;
116 }
117
test_div_v4sf_3(__vector float * a,__vector float * b,int * p)118 int *test_div_v4sf_3 (__vector float *a, __vector float *b, int *p)
119 {
120 if (__builtin_vsx_xvtdivsp_fg (*a, *b))
121 *p++ = 1;
122
123 return p;
124 }
125
test_sqrt_v4sf_1(__vector float * a,int * p)126 void test_sqrt_v4sf_1 (__vector float *a, int *p)
127 {
128 p[0] = __builtin_vsx_xvtsqrtsp_fe (*a);
129 p[1] = __builtin_vsx_xvtsqrtsp_fg (*a);
130 }
131
test_sqrt_v4sf_2(__vector float * a,int * p)132 int *test_sqrt_v4sf_2 (__vector float *a, int *p)
133 {
134 if (__builtin_vsx_xvtsqrtsp_fe (*a))
135 *p++ = 1;
136
137 return p;
138 }
139
test_sqrt_v4sf_3(__vector float * a,int * p)140 int *test_sqrt_v4sf_3 (__vector float *a, int *p)
141 {
142 if (__builtin_vsx_xvtsqrtsp_fg (*a))
143 *p++ = 1;
144
145 return p;
146 }
147