Debian Codegraph @

gcc/testsuite/gcc.target/powerpc/bfp/vec-insert-exp-8.c

raw
1 /* { dg-do run { target { powerpc*-*-* } } } */
2 /* { dg-require-effective-target p9vector_hw } */
3 /* { dg-options "-mdejagnu-cpu=power9" } */
4
5 #include <altivec.h>
6 #include <stdlib.h>
7
8 __vector float
9 make_floats (__vector unsigned int *significands_p,
10 __vector unsigned int *exponents_p)
11 {
12 __vector unsigned int significands = *significands_p;
13 __vector unsigned int exponents = *exponents_p;
14
15 return vec_insert_exp (significands, exponents);
16 }
17
18 int
19 main ()
20 {
21 __vector unsigned int significands;
22 __vector unsigned int exponents;
23 __vector float result;
24
25 /* 24 bits in significand, plus the sign bit: 0x80ffffff */
26 significands[0] = 0x00800000; /* 1.0 */
27 significands[1] = 0x00c00000; /* 1.5 */
28 significands[2] = 0x80e00000; /* -1.75 */
29 significands[3] = 0x80c00000; /* -1.5 */
30
31 exponents[0] = 127; /* exp = 0: 1.0 */
32 exponents[1] = 128; /* exp = 1: 3.0.0 */
33 exponents[2] = 129; /* exp = 2: -7.0 */
34 exponents[3] = 125; /* exp = -2: -0.375 */
35
36 result = make_floats (&significands, &exponents);
37 if ((result[0] != 1.0f) ||
38 (result[1] != 3.0f) || (result[2] != -7.0f) || (result[3] != -0.375f))
39 abort();
40 return 0;
41 }
42