Debian Codegraph @

gcc/testsuite/gcc.target/powerpc/bfp/scalar-test-data-class-15.c

raw
1 /* { dg-do run { target { powerpc*-*-* } } } */
2 /* { dg-require-effective-target int128 } */
3 /* { dg-require-effective-target p9vector_hw } */
4 /* { dg-options "-mdejagnu-cpu=power9" } */
5
6 #include <altivec.h>
7 #include <stdbool.h>
8 #include <stdlib.h>
9
10 bool
11 test_infinity (__ieee128 *p)
12 {
13 __ieee128 source = *p;
14
15 /*
16 0x40 Test for NaN
17 0x20 Test for +Infinity
18 0x10 Test for -Infinity
19 0x08 Test for +Zero
20 0x04 Test for -Zero
21 0x02 Test for +Denormal
22 0x01 Test for -Denormal
23 */
24 return scalar_test_data_class (source, 0x30);
25 }
26
27 int
28 main ()
29 {
30 /* Infinity is represented by a biased exponent value of:
31 * 255 in single format
32 * 2047 in double format
33 * 32767 in ieee128 format
34 * and a zero fraction value. */
35 __int128 plus_significand = (__int128) 0;
36 __int128 minus_significand = ((__int128) 0x1) << 127;
37 __int128 a_number_significand = (((__int128) 0x1) << 112);
38
39 unsigned long long int infinite_exponent = 0x7fff;
40 unsigned long long int a_number_exponent = 16383;
41
42 __ieee128 plus_infinity =
43 scalar_insert_exp (plus_significand, infinite_exponent);
44 __ieee128 minus_infinity =
45 scalar_insert_exp (minus_significand, infinite_exponent);
46 __ieee128 a_number =
47 scalar_insert_exp (a_number_significand, a_number_exponent);
48
49 if (!test_infinity (&plus_infinity))
50 abort ();
51 if (!test_infinity (&minus_infinity))
52 abort ();
53 if (test_infinity (&a_number))
54 abort ();
55 return 0;
56 }