Add execution + assembler tests of AArch64 TRN Intrinsics.
[official-gcc.git] / gcc / testsuite / gcc.target / aarch64 / vadd_f64.c
blobc3bf7349597aa9b75e0bc34cfd4cde4dc16b95f3
1 /* Test vadd works correctly. */
2 /* { dg-do run } */
3 /* { dg-options "--save-temps" } */
5 #include <arm_neon.h>
7 #define FLT_EPSILON __FLT_EPSILON__
8 #define DBL_EPSILON __DBL_EPSILON__
10 #define TESTA0 0.33333
11 #define TESTA1 -1.7777
12 #define TESTA2 0
13 #define TESTA3 1.23456
14 /* 2^54, double has 53 significand bits
15 according to Double-precision floating-point format. */
16 #define TESTA4 18014398509481984
17 #define TESTA5 (1.0 / TESTA4)
19 #define TESTB0 0.66667
20 #define TESTB1 2
21 #define TESTB2 0
22 #define TESTB3 -2
23 #define TESTB4 1.0
24 #define TESTB5 2.0
26 #define ANSW0 1
27 #define ANSW1 0.2223
28 #define ANSW2 0
29 #define ANSW3 -0.76544
30 #define ANSW4 TESTA4
31 #define ANSW5 2.0
33 extern void abort (void);
35 #define EPSILON __DBL_EPSILON__
36 #define ABS(a) __builtin_fabs (a)
37 #define ISNAN(a) __builtin_isnan (a)
38 #define FP_equals(a, b, epsilon) \
39 ( \
40 ((a) == (b)) \
41 || (ISNAN (a) && ISNAN (b)) \
42 || (ABS (a - b) < epsilon) \
45 int
46 test_vadd_f64 ()
48 float64x1_t a;
49 float64x1_t b;
50 float64x1_t c;
52 a = TESTA0;
53 b = TESTB0;
54 c = ANSW0;
56 a = vadd_f64 (a, b);
57 if (!FP_equals (a, c, EPSILON))
58 return 1;
60 a = TESTA1;
61 b = TESTB1;
62 c = ANSW1;
64 a = vadd_f64 (a, b);
65 if (!FP_equals (a, c, EPSILON))
66 return 1;
68 a = TESTA2;
69 b = TESTB2;
70 c = ANSW2;
72 a = vadd_f64 (a, b);
73 if (!FP_equals (a, c, EPSILON))
74 return 1;
76 a = TESTA3;
77 b = TESTB3;
78 c = ANSW3;
80 a = vadd_f64 (a, b);
81 if (!FP_equals (a, c, EPSILON))
82 return 1;
84 a = TESTA4;
85 b = TESTB4;
86 c = ANSW4;
88 a = vadd_f64 (a, b);
89 if (!FP_equals (a, c, EPSILON))
90 return 1;
92 a = TESTA5;
93 b = TESTB5;
94 c = ANSW5;
96 a = vadd_f64 (a, b);
97 if (!FP_equals (a, c, EPSILON))
98 return 1;
100 return 0;
103 /* { dg-final { scan-assembler-times "fadd\\td\[0-9\]+, d\[0-9\]+, d\[0-9\]+" 6 } } */
106 main (int argc, char **argv)
108 if (test_vadd_f64 ())
109 abort ();
111 return 0;
114 /* { dg-final { cleanup-saved-temps } } */