mve: Fix vsetq_lane for 64-bit elements with lane 1 [PR 115611]
[official-gcc.git] / gcc / testsuite / gcc.dg / torture / builtin-complex-1.c
blob8dc91a555a2d3d87f1343879e87d797e88bf0c7b
1 /* Test __builtin_complex semantics. */
2 /* { dg-do run } */
3 /* { dg-options "-std=c11 -pedantic-errors" } */
4 /* { dg-require-effective-target inf } */
5 /* { dg-add-options ieee } */
6 /* { dg-skip-if "double support is incomplete" { "avr-*-*" } } */
8 extern void exit (int);
9 extern void abort (void);
11 #define COMPARE_BODY(A, B, TYPE, COPYSIGN) \
12 do { \
13 TYPE s1 = COPYSIGN ((TYPE) 1.0, A); \
14 TYPE s2 = COPYSIGN ((TYPE) 1.0, B); \
15 if (s1 != s2) \
16 abort (); \
17 if ((__builtin_isnan (A) != 0) != (__builtin_isnan (B) != 0)) \
18 abort (); \
19 if ((A != B) != (__builtin_isnan (A) != 0)) \
20 abort (); \
21 } while (0)
23 void
24 comparef (float a, float b)
26 COMPARE_BODY (a, b, float, __builtin_copysignf);
29 void
30 compare (double a, double b)
32 COMPARE_BODY (a, b, double, __builtin_copysign);
35 void
36 comparel (long double a, long double b)
38 COMPARE_BODY (a, b, long double, __builtin_copysignl);
41 void
42 comparecf (_Complex float a, float r, float i)
44 comparef (__real__ a, r);
45 comparef (__imag__ a, i);
48 void
49 comparec (_Complex double a, double r, double i)
51 compare (__real__ a, r);
52 compare (__imag__ a, i);
55 void
56 comparecl (_Complex long double a, long double r, long double i)
58 comparel (__real__ a, r);
59 comparel (__imag__ a, i);
62 #define VERIFY(A, B, TYPE, COMPARE) \
63 do { \
64 TYPE a = A; \
65 TYPE b = B; \
66 _Complex TYPE cr = __builtin_complex (a, b); \
67 static _Complex TYPE cs = __builtin_complex (A, B); \
68 COMPARE (cr, A, B); \
69 COMPARE (cs, A, B); \
70 } while (0)
72 #define ALL_CHECKS(PZ, NZ, NAN, INF, TYPE, COMPARE) \
73 do { \
74 VERIFY (PZ, PZ, TYPE, COMPARE); \
75 VERIFY (PZ, NZ, TYPE, COMPARE); \
76 VERIFY (PZ, NAN, TYPE, COMPARE); \
77 VERIFY (PZ, INF, TYPE, COMPARE); \
78 VERIFY (NZ, PZ, TYPE, COMPARE); \
79 VERIFY (NZ, NZ, TYPE, COMPARE); \
80 VERIFY (NZ, NAN, TYPE, COMPARE); \
81 VERIFY (NZ, INF, TYPE, COMPARE); \
82 VERIFY (NAN, PZ, TYPE, COMPARE); \
83 VERIFY (NAN, NZ, TYPE, COMPARE); \
84 VERIFY (NAN, NAN, TYPE, COMPARE); \
85 VERIFY (NAN, INF, TYPE, COMPARE); \
86 VERIFY (INF, PZ, TYPE, COMPARE); \
87 VERIFY (INF, NZ, TYPE, COMPARE); \
88 VERIFY (INF, NAN, TYPE, COMPARE); \
89 VERIFY (INF, INF, TYPE, COMPARE); \
90 } while (0)
92 void
93 check_float (void)
95 ALL_CHECKS (0.0f, -0.0f, __builtin_nanf(""), __builtin_inff(),
96 float, comparecf);
99 void
100 check_double (void)
102 ALL_CHECKS (0.0, -0.0, __builtin_nan(""), __builtin_inf(),
103 double, comparec);
106 void
107 check_long_double (void)
109 ALL_CHECKS (0.0l, -0.0l, __builtin_nanl(""), __builtin_infl(),
110 long double, comparecl);
114 main (void)
116 check_float ();
117 check_double ();
118 check_long_double ();
119 exit (0);