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