1 /* Test vreinterpret_f64_* and vreinterpret_*_f64 intrinsics work correctly. */
3 /* { dg-options "-O3" } */
7 extern void abort (void);
9 #define ABS(a) __builtin_fabs (a)
10 #define ISNAN(a) __builtin_isnan (a)
12 #define DOUBLE_EQUALS(a, b, epsilon) \
15 || (ISNAN (a) && ISNAN (b)) \
16 || (ABS (a - b) < epsilon) \
19 /* Pi accurate up to 16 digits.
20 Further digits are a closest binary approximation. */
21 #define PI_F64 3.14159265358979311599796346854
22 /* Hex representation in Double (IEEE754 Double precision 64-bit) is:
23 0x400921FB54442D18. */
25 /* E accurate up to 16 digits.
26 Further digits are a closest binary approximation. */
27 #define E_F64 2.71828182845904509079559829843
28 /* Hex representation in Double (IEEE754 Double precision 64-bit) is:
29 0x4005BF0A8B145769. */
31 float32x2_t
__attribute__ ((noinline
))
32 wrap_vreinterpret_f32_f64 (float64x1_t __a
)
34 return vreinterpret_f32_f64 (__a
);
37 int __attribute__ ((noinline
))
38 test_vreinterpret_f32_f64 ()
42 float64_t c
[1] = { PI_F64
};
43 /* Values { 0x54442D18, 0x400921FB } reinterpreted as f32. */
44 float32_t d
[2] = { 3.3702805504E12
, 2.1426990032196044921875E0
};
49 b
= wrap_vreinterpret_f32_f64 (a
);
51 for (i
= 0; i
< 2; i
++)
52 if (!DOUBLE_EQUALS (d
[i
], e
[i
], __FLT_EPSILON__
))
57 int8x8_t
__attribute__ ((noinline
))
58 wrap_vreinterpret_s8_f64 (float64x1_t __a
)
60 return vreinterpret_s8_f64 (__a
);
63 int __attribute__ ((noinline
))
64 test_vreinterpret_s8_f64 ()
68 float64_t c
[1] = { PI_F64
};
69 int8_t d
[8] = { 0x18, 0x2D, 0x44, 0x54, 0xFB, 0x21, 0x09, 0x40 };
74 b
= wrap_vreinterpret_s8_f64 (a
);
76 for (i
= 0; i
< 8; i
++)
82 int16x4_t
__attribute__ ((noinline
))
83 wrap_vreinterpret_s16_f64 (float64x1_t __a
)
85 return vreinterpret_s16_f64 (__a
);
88 int __attribute__ ((noinline
))
89 test_vreinterpret_s16_f64 ()
93 float64_t c
[1] = { PI_F64
};
94 int16_t d
[4] = { 0x2D18, 0x5444, 0x21FB, 0x4009 };
99 b
= wrap_vreinterpret_s16_f64 (a
);
101 for (i
= 0; i
< 4; i
++)
107 int32x2_t
__attribute__ ((noinline
))
108 wrap_vreinterpret_s32_f64 (float64x1_t __a
)
110 return vreinterpret_s32_f64 (__a
);
113 int __attribute__ ((noinline
))
114 test_vreinterpret_s32_f64 ()
118 float64_t c
[1] = { PI_F64
};
119 int32_t d
[2] = { 0x54442D18, 0x400921FB };
124 b
= wrap_vreinterpret_s32_f64 (a
);
126 for (i
= 0; i
< 2; i
++)
132 int64x1_t
__attribute__ ((noinline
))
133 wrap_vreinterpret_s64_f64 (float64x1_t __a
)
135 return vreinterpret_s64_f64 (__a
);
138 int __attribute__ ((noinline
))
139 test_vreinterpret_s64_f64 ()
143 float64_t c
[1] = { PI_F64
};
144 int64_t d
[1] = { 0x400921FB54442D18 };
149 b
= wrap_vreinterpret_s64_f64 (a
);
156 float32x4_t
__attribute__ ((noinline
))
157 wrap_vreinterpretq_f32_f64 (float64x2_t __a
)
159 return vreinterpretq_f32_f64 (__a
);
162 int __attribute__ ((noinline
))
163 test_vreinterpretq_f32_f64 ()
167 float64_t c
[2] = { PI_F64
, E_F64
};
169 /* Values corresponding to f32 reinterpret of
170 { 0x54442D18, 0x400921FB, 0x8B145769, 0x4005BF0A }. */
171 float32_t d
[4] = { 3.3702805504E12
,
172 2.1426990032196044921875E0
,
173 -2.8569523269651966444143014594E-32,
174 2.089785099029541015625E0
};
179 b
= wrap_vreinterpretq_f32_f64 (a
);
181 for (i
= 0; i
< 4; i
++)
183 if (!DOUBLE_EQUALS (d
[i
], e
[i
], __FLT_EPSILON__
))
189 int8x16_t
__attribute__ ((noinline
))
190 wrap_vreinterpretq_s8_f64 (float64x2_t __a
)
192 return vreinterpretq_s8_f64 (__a
);
195 int __attribute__ ((noinline
))
196 test_vreinterpretq_s8_f64 ()
200 float64_t c
[2] = { PI_F64
, E_F64
};
201 int8_t d
[16] = { 0x18, 0x2D, 0x44, 0x54, 0xFB, 0x21, 0x09, 0x40,
202 0x69, 0x57, 0x14, 0x8B, 0x0A, 0xBF, 0x05, 0x40 };
207 b
= wrap_vreinterpretq_s8_f64 (a
);
209 for (i
= 0; i
< 16; i
++)
215 int16x8_t
__attribute__ ((noinline
))
216 wrap_vreinterpretq_s16_f64 (float64x2_t __a
)
218 return vreinterpretq_s16_f64 (__a
);
221 int __attribute__ ((noinline
))
222 test_vreinterpretq_s16_f64 ()
226 float64_t c
[2] = { PI_F64
, E_F64
};
227 int16_t d
[8] = { 0x2D18, 0x5444, 0x21FB, 0x4009,
228 0x5769, 0x8B14, 0xBF0A, 0x4005 };
233 b
= wrap_vreinterpretq_s16_f64 (a
);
235 for (i
= 0; i
< 8; i
++)
241 int32x4_t
__attribute__ ((noinline
))
242 wrap_vreinterpretq_s32_f64 (float64x2_t __a
)
244 return vreinterpretq_s32_f64 (__a
);
247 int __attribute__ ((noinline
))
248 test_vreinterpretq_s32_f64 ()
252 float64_t c
[2] = { PI_F64
, E_F64
};
253 int32_t d
[4] = { 0x54442D18, 0x400921FB, 0x8B145769, 0x4005BF0A };
258 b
= wrap_vreinterpretq_s32_f64 (a
);
260 for (i
= 0; i
< 4; i
++)
266 int64x2_t
__attribute__ ((noinline
))
267 wrap_vreinterpretq_s64_f64 (float64x2_t __a
)
269 return vreinterpretq_s64_f64 (__a
);
272 int __attribute__ ((noinline
))
273 test_vreinterpretq_s64_f64 ()
277 float64_t c
[2] = { PI_F64
, E_F64
};
278 int64_t d
[2] = { 0x400921FB54442D18, 0x4005BF0A8B145769 };
283 b
= wrap_vreinterpretq_s64_f64 (a
);
285 for (i
= 0; i
< 2; i
++)
291 float64x1_t
__attribute__ ((noinline
))
292 wrap_vreinterpret_f64_f32 (float32x2_t __a
)
294 return vreinterpret_f64_f32 (__a
);
297 int __attribute__ ((noinline
))
298 test_vreinterpret_f64_f32 ()
302 /* Values { 0x54442D18, 0x400921FB } reinterpreted as f32. */
303 float32_t c
[2] = { 3.3702805504E12
, 2.1426990032196044921875E0
};
304 float64_t d
[1] = { PI_F64
};
309 b
= wrap_vreinterpret_f64_f32 (a
);
311 if (!DOUBLE_EQUALS (d
[0], e
[0], __DBL_EPSILON__
))
316 float64x1_t
__attribute__ ((noinline
))
317 wrap_vreinterpret_f64_s8 (int8x8_t __a
)
319 return vreinterpret_f64_s8 (__a
);
322 int __attribute__ ((noinline
))
323 test_vreinterpret_f64_s8 ()
327 int8_t c
[8] = { 0x18, 0x2D, 0x44, 0x54, 0xFB, 0x21, 0x09, 0x40 };
328 float64_t d
[1] = { PI_F64
};
333 b
= wrap_vreinterpret_f64_s8 (a
);
335 if (!DOUBLE_EQUALS (d
[0], e
[0], __DBL_EPSILON__
))
340 float64x1_t
__attribute__ ((noinline
))
341 wrap_vreinterpret_f64_s16 (int16x4_t __a
)
343 return vreinterpret_f64_s16 (__a
);
346 int __attribute__ ((noinline
))
347 test_vreinterpret_f64_s16 ()
351 int16_t c
[4] = { 0x2D18, 0x5444, 0x21FB, 0x4009 };
352 float64_t d
[1] = { PI_F64
};
357 b
= wrap_vreinterpret_f64_s16 (a
);
359 if (!DOUBLE_EQUALS (d
[0], e
[0], __DBL_EPSILON__
))
364 float64x1_t
__attribute__ ((noinline
))
365 wrap_vreinterpret_f64_s32 (int32x2_t __a
)
367 return vreinterpret_f64_s32 (__a
);
370 int __attribute__ ((noinline
))
371 test_vreinterpret_f64_s32 ()
375 int32_t c
[2] = { 0x54442D18, 0x400921FB };
376 float64_t d
[1] = { PI_F64
};
381 b
= wrap_vreinterpret_f64_s32 (a
);
383 if (!DOUBLE_EQUALS (d
[0], e
[0], __DBL_EPSILON__
))
388 float64x1_t
__attribute__ ((noinline
))
389 wrap_vreinterpret_f64_s64 (int64x1_t __a
)
391 return vreinterpret_f64_s64 (__a
);
394 int __attribute__ ((noinline
))
395 test_vreinterpret_f64_s64 ()
399 int64_t c
[1] = { 0x400921FB54442D18 };
400 float64_t d
[1] = { PI_F64
};
404 b
= wrap_vreinterpret_f64_s64 (a
);
406 if (!DOUBLE_EQUALS (d
[0], e
[0], __DBL_EPSILON__
))
411 float64x2_t
__attribute__ ((noinline
))
412 wrap_vreinterpretq_f64_f32 (float32x4_t __a
)
414 return vreinterpretq_f64_f32 (__a
);
417 int __attribute__ ((noinline
))
418 test_vreinterpretq_f64_f32 ()
422 /* Values corresponding to f32 reinterpret of
423 { 0x54442D18, 0x400921FB, 0x8B145769, 0x4005BF0A }. */
424 float32_t c
[4] = { 3.3702805504E12
,
425 2.1426990032196044921875E0
,
426 -2.8569523269651966444143014594E-32,
427 2.089785099029541015625E0
};
429 float64_t d
[2] = { PI_F64
, E_F64
};
434 b
= wrap_vreinterpretq_f64_f32 (a
);
436 for (i
= 0; i
< 2; i
++)
437 if (!DOUBLE_EQUALS (d
[i
], e
[i
], __DBL_EPSILON__
))
442 float64x2_t
__attribute__ ((noinline
))
443 wrap_vreinterpretq_f64_s8 (int8x16_t __a
)
445 return vreinterpretq_f64_s8 (__a
);
448 int __attribute__ ((noinline
))
449 test_vreinterpretq_f64_s8 ()
453 int8_t c
[16] = { 0x18, 0x2D, 0x44, 0x54, 0xFB, 0x21, 0x09, 0x40,
454 0x69, 0x57, 0x14, 0x8B, 0x0A, 0xBF, 0x05, 0x40 };
455 float64_t d
[2] = { PI_F64
, E_F64
};
460 b
= wrap_vreinterpretq_f64_s8 (a
);
462 for (i
= 0; i
< 2; i
++)
463 if (!DOUBLE_EQUALS (d
[i
], e
[i
], __DBL_EPSILON__
))
468 float64x2_t
__attribute__ ((noinline
))
469 wrap_vreinterpretq_f64_s16 (int16x8_t __a
)
471 return vreinterpretq_f64_s16 (__a
);
474 int __attribute__ ((noinline
))
475 test_vreinterpretq_f64_s16 ()
479 int16_t c
[8] = { 0x2D18, 0x5444, 0x21FB, 0x4009,
480 0x5769, 0x8B14, 0xBF0A, 0x4005 };
481 float64_t d
[2] = { PI_F64
, E_F64
};
486 b
= wrap_vreinterpretq_f64_s16 (a
);
488 for (i
= 0; i
< 2; i
++)
489 if (!DOUBLE_EQUALS (d
[i
], e
[i
], __DBL_EPSILON__
))
494 float64x2_t
__attribute__ ((noinline
))
495 wrap_vreinterpretq_f64_s32 (int32x4_t __a
)
497 return vreinterpretq_f64_s32 (__a
);
500 int __attribute__ ((noinline
))
501 test_vreinterpretq_f64_s32 ()
505 int32_t c
[4] = { 0x54442D18, 0x400921FB, 0x8B145769, 0x4005BF0A };
506 float64_t d
[2] = { PI_F64
, E_F64
};
511 b
= wrap_vreinterpretq_f64_s32 (a
);
513 for (i
= 0; i
< 2; i
++)
514 if (!DOUBLE_EQUALS (d
[i
], e
[i
], __DBL_EPSILON__
))
519 float64x2_t
__attribute__ ((noinline
))
520 wrap_vreinterpretq_f64_s64 (int64x2_t __a
)
522 return vreinterpretq_f64_s64 (__a
);
525 int __attribute__ ((noinline
))
526 test_vreinterpretq_f64_s64 ()
530 int64_t c
[2] = { 0x400921FB54442D18, 0x4005BF0A8B145769 };
531 float64_t d
[2] = { PI_F64
, E_F64
};
536 b
= wrap_vreinterpretq_f64_s64 (a
);
538 for (i
= 0; i
< 2; i
++)
539 if (!DOUBLE_EQUALS (d
[i
], e
[i
], __DBL_EPSILON__
))
545 main (int argc
, char **argv
)
547 if (test_vreinterpret_f32_f64 ())
550 if (test_vreinterpret_s8_f64 ())
552 if (test_vreinterpret_s16_f64 ())
554 if (test_vreinterpret_s32_f64 ())
556 if (test_vreinterpret_s64_f64 ())
559 if (test_vreinterpretq_f32_f64 ())
562 if (test_vreinterpretq_s8_f64 ())
564 if (test_vreinterpretq_s16_f64 ())
566 if (test_vreinterpretq_s32_f64 ())
568 if (test_vreinterpretq_s64_f64 ())
571 if (test_vreinterpret_f64_f32 ())
574 if (test_vreinterpret_f64_s8 ())
576 if (test_vreinterpret_f64_s16 ())
578 if (test_vreinterpret_f64_s32 ())
580 if (test_vreinterpret_f64_s64 ())
583 if (test_vreinterpretq_f64_f32 ())
586 if (test_vreinterpretq_f64_s8 ())
588 if (test_vreinterpretq_f64_s16 ())
590 if (test_vreinterpretq_f64_s32 ())
592 if (test_vreinterpretq_f64_s64 ())