2 /* { dg-options "-O2 -ffast-math" } */
6 long double fabsl(long double);
7 double cabs(__complex__
double);
8 float cabsf(__complex__
float);
9 long double cabsl(__complex__
long double);
11 void link_error (void);
13 void test(__complex__
double x
, double a
, double b
)
15 if (cabs(x
) != cabs(-x
))
18 if (cabs(x
) != cabs(~x
))
21 if (fabs(a
) * __builtin_sqrt(2) != cabs (a
+a
*1i
))
24 if (fabs(a
) * __builtin_sqrt(2) != cabs (a
*1i
+a
))
27 if (fabs(a
) * __builtin_sqrt(2) != cabs (-a
+a
*-1i
))
30 if (fabs(a
) * __builtin_sqrt(2) != cabs (-a
+-a
*1i
))
33 if (fabs(a
) * __builtin_sqrt(2) != cabs (-a
-a
*1i
))
36 if (fabs(a
) * __builtin_sqrt(2) != cabs (a
*-1i
-a
))
39 if (fabs(a
) * __builtin_sqrt(2) != cabs (-a
*1i
-a
))
42 if (fabs(a
) * __builtin_sqrt(2) != cabs (a
*-1i
+-a
))
45 if (fabs(a
) * __builtin_sqrt(2) != cabs (-a
*1i
+-a
))
48 if (fabs(a
*b
) * __builtin_sqrt(2) != cabs (a
*b
-(-b
*a
*1i
)))
51 if (fabs(a
*b
) * __builtin_sqrt(2) != cabs (a
*b
*1i
-a
*-b
))
55 void testf(__complex__
float x
, float a
, float b
)
57 if (cabsf(x
) != cabsf(-x
))
60 if (cabsf(x
) != cabsf(~x
))
63 if (fabsf(a
) * __builtin_sqrtf(2) != cabsf (a
+a
*1i
))
66 if (fabsf(a
) * __builtin_sqrtf(2) != cabsf (a
*1i
+a
))
69 if (fabsf(a
) * __builtin_sqrtf(2) != cabsf (-a
+a
*-1i
))
72 if (fabsf(a
) * __builtin_sqrtf(2) != cabsf (-a
+-a
*1i
))
75 if (fabsf(a
) * __builtin_sqrtf(2) != cabsf (-a
-a
*1i
))
78 if (fabsf(a
) * __builtin_sqrtf(2) != cabsf (a
*-1i
-a
))
81 if (fabsf(a
) * __builtin_sqrtf(2) != cabsf (-a
*1i
-a
))
84 if (fabsf(a
) * __builtin_sqrtf(2) != cabsf (a
*-1i
+-a
))
87 if (fabsf(a
) * __builtin_sqrtf(2) != cabsf (-a
*1i
+-a
))
90 if (fabsf(a
*b
) * __builtin_sqrtf(2) != cabsf (a
*b
-(-b
*a
*1i
)))
93 if (fabsf(a
*b
) * __builtin_sqrtf(2) != cabsf (a
*b
*1i
-a
*-b
))
97 void testl(__complex__
long double x
, long double a
, long double b
)
99 if (cabsl(x
) != cabsl(-x
))
102 if (cabsl(x
) != cabsl(~x
))
105 if (fabsl(a
) * __builtin_sqrtl(2) != cabsl (a
+a
*1i
))
108 if (fabsl(a
) * __builtin_sqrtl(2) != cabsl (a
*1i
+a
))
111 if (fabsl(a
) * __builtin_sqrtl(2) != cabsl (-a
+a
*-1i
))
114 if (fabsl(a
) * __builtin_sqrtl(2) != cabsl (-a
+-a
*1i
))
117 if (fabsl(a
) * __builtin_sqrtl(2) != cabsl (-a
-a
*1i
))
120 if (fabsl(a
) * __builtin_sqrtl(2) != cabsl (a
*-1i
-a
))
123 if (fabsl(a
) * __builtin_sqrtl(2) != cabsl (-a
*1i
-a
))
126 if (fabsl(a
) * __builtin_sqrtl(2) != cabsl (a
*-1i
+-a
))
129 if (fabsl(a
) * __builtin_sqrtl(2) != cabsl (-a
*1i
+-a
))
132 if (fabsl(a
*b
) * __builtin_sqrtl(2) != cabsl (a
*b
-(-b
*a
*1i
)))
135 if (fabsl(a
*b
) * __builtin_sqrtl(2) != cabsl (a
*b
*1i
-a
*-b
))