Debian Codegraph @

gcc/testsuite/gcc.target/powerpc/bfp/vec-test-data-class-9.c

raw
1 /* { dg-do run { target { powerpc*-*-* } } } */
2 /* { dg-require-effective-target has_arch_ppc64 } */
3 /* { dg-require-effective-target p9vector_hw } */
4 /* { dg-options "-mdejagnu-cpu=power9" } */
5
6 #include <altivec.h>
7 #include <stdlib.h>
8
9 /* Flags to select tests:
10 0x40 Test for NaN
11 0x20 Test for +Infinity
12 0x10 Test for -Infinity
13 0x08 Test for +Zero
14 0x04 Test for -Zero
15 0x02 Test for +Denormal
16 0x01 Test for -Denormal */
17
18 __vector bool long long int
19 test_nan (__vector double *p)
20 {
21 __vector double source = *p;
22
23 return vec_test_data_class (source, 0x40);
24 }
25
26 __vector bool long long int
27 test_infinity (__vector double *p)
28 {
29 __vector double source = *p;
30
31 return vec_test_data_class (source, 0x30);
32 }
33
34 __vector bool long long int
35 test_zero (__vector double *p)
36 {
37 __vector double source = *p;
38
39 return vec_test_data_class (source, 0x0c);
40 }
41
42 __vector bool long long int
43 test_denormal (__vector double *p)
44 {
45 __vector double source = *p;
46
47 return vec_test_data_class (source, 0x03);
48 }
49
50 int
51 main ()
52 {
53 __vector double special_argument;
54 __vector double nonspecial_argument;
55 __vector bool long long int result;
56
57 unsigned long long int signaling_significand =
58 0x0017000000000000ULL;
59 unsigned long long int quiet_significand =
60 0x001f000000000000ULL;
61 unsigned long long int one_significand =
62 0x0010000000000000ULL;
63 unsigned long long int three_significand =
64 0x0018000000000000ULL;
65 unsigned long long int five_significand =
66 0x0014000000000000ULL;
67 unsigned long long int zero_significand =
68 0x0000000000000000ULL;
69 unsigned long long int minus_zero_significand =
70 0x8000000000000000ULL;
71
72 nonspecial_argument[0] = -3.825;
73 nonspecial_argument[1] = 3.14159;
74
75 /* A NaN is represented with the maximum biased exponent value and a
76 * non-zero fraction value. The sign bit ignored. If the
77 * high-order bit of the fraction field is 0, then the NaN
78 * is a Signaling NaN. Otherwise, it is a Quiet NaN. */
79 special_argument[0] = scalar_insert_exp (signaling_significand, 2047);
80 special_argument[1] = scalar_insert_exp (quiet_significand, 2047);
81 result = test_nan (&special_argument);
82 if (!result[0] || !result[1])
83 abort ();
84 result = test_nan (&nonspecial_argument);
85 if (result[0] || result[1])
86 abort ();
87
88 /* Infinity is represented by a biased exponent value of:
89 * 255 in single format
90 * 2047 in double format
91 * and a zero fraction value. The difference between +infinity and
92 * -infinity is the value of the sign bit. */
93 special_argument[0] = scalar_insert_exp (zero_significand, 2047);
94 special_argument[1] = scalar_insert_exp (minus_zero_significand, 2047);
95 result = test_infinity (&special_argument);
96 if (!result[0] || !result[1])
97 abort ();
98 result = test_infinity (&nonspecial_argument);
99 if (result[0] || result[1])
100 abort ();
101
102 /* A Zero value has a biased exponent value of zero and a zero
103 * fraction value. The sign may be either positive or negative. */
104 special_argument[0] = scalar_insert_exp (minus_zero_significand, 0);
105 special_argument[1] = scalar_insert_exp (zero_significand, 0);
106 result = test_zero (&special_argument);
107 if (!result[0] || !result[1])
108 abort ();
109 result = test_zero (&nonspecial_argument);
110 if (result[0] || result[1])
111 abort ();
112
113 /* A Denormal number has a biased exponent value of zero and a
114 * non-zero fraction value. */
115 special_argument[0] = scalar_insert_exp (five_significand, 0);
116 special_argument[1] = scalar_insert_exp (three_significand, 0);
117 result = test_denormal (&special_argument);
118 if (!result[0] || !result[1])
119 abort ();
120 result = test_denormal (&nonspecial_argument);
121 if (result[0] || result[1])
122 abort ();
123 return 0;
124 }
125