[testsuite] require sqrt_insn effective target where needed
[official-gcc.git] / gcc / testsuite / gcc.target / powerpc / builtins-1-p9-runnable.c
blob976654155b1a692e90fb29def2deb9e0bd8f2ee9
1 /* { dg-do run } */
2 /* { dg-require-effective-target p9vector_hw } */
3 /* { dg-options "-O2 -mdejagnu-cpu=power9" } */
5 #include <altivec.h>
6 #include <stdio.h>
8 void abort (void);
10 int main() {
11 int i;
12 vector float vfa, vfb;
13 vector unsigned short vresult, vexpected;
15 vfa = (vector float){0.4, 1.6, 20.0, 99.9 };
16 vfb = (vector float){10.0, -2.0, 70.0, 999.0 };
18 /* Expected results. */
19 #ifdef __BIG_ENDIAN__
20 vexpected = (vector unsigned short) { 0x4900, 0xc000, 0x5460, 0x63ce,
21 0x3666, 0x3e66, 0x4d00, 0x563e };
22 #else
23 vexpected = (vector unsigned short) { 0x3666, 0x3e66, 0x4d00, 0x563e,
24 0x4900, 0xc000, 0x5460, 0x63ce };
25 #endif
28 vresult = vec_pack_to_short_fp32 (vfa, vfb);
29 This built-in converts a pair of vector floats into a single vector of
30 packed half-precision (F16) values. The result type is a vector of
31 signed shorts.
32 The expected codegen for this builtin is
33 xvcvsphp t, vfa
34 xvcvsphp u, vfb
35 if (little endian)
36 vpkuwum vresult, t, u
37 else
38 vpkuwum vresult, u, t
41 vresult = vec_pack_to_short_fp32 (vfa, vfb);
43 #ifdef DEBUG
44 for(i = 0; i< 4; i++) { printf("i=[%d] %f \n",i,vfa[i]); }
45 for(i = 0; i< 4; i++) { printf("i=[%d] %f \n",i+4,vfb[i]); }
46 for(i = 0; i< 8; i++) { printf("i=[%d] %d \n",i,vresult[i]); }
47 #endif
49 for(i = 0; i< 8; i++) {
50 if (vresult[i] != vexpected[i]) {
51 printf("i=[%d] 0x%x != 0x%x \n",i,vresult[i],vexpected[i]);
52 abort();