Debian Codegraph @

gcc/testsuite/gcc.target/i386/avx-ne-convert-vbcstnebf162ps-2.c

raw
1 /* { dg-do run } */
2 /* { dg-options "-mavxneconvert -O2" } */
3 /* { dg-require-effective-target avxneconvert } */
4 #define AVXNECONVERT
5 #include <stdint.h>
6
7 #ifndef CHECK
8 #define CHECK "avx-check.h"
9 #endif
10
11 #ifndef TEST
12 #define TEST avx_test
13 #endif
14
15 #include CHECK
16
17 typedef union
18 {
19 uint32_t int32;
20 float flt;
21 } float_int_t;
22
23 static uint16_t convert_fp32_to_bf16 (float fp)
24 {
25 float_int_t fi;
26 fi.flt = fp;
27 return ((fi.int32 >> 16) & 0xffff);
28 }
29
30 void TEST (void)
31 {
32 union128 dst_128;
33 union256 dst_256;
34 float res_ref_128[4], res_ref_256[8], fp32;
35 uint16_t var;
36 fp32 = (float) 3 * 2 + 5.5;
37 for (int i = 0; i < 4; i++)
38 {
39 res_ref_128[i] = fp32;
40 dst_128.a[i] = 117;
41 }
42 for (int i = 0; i < 8; i++)
43 {
44 res_ref_256[i] = fp32;
45 dst_256.a[i] = 117;
46 }
47 var = convert_fp32_to_bf16 (fp32);
48 dst_128.x = _mm_bcstnebf16_ps (&var);
49 dst_256.x = _mm256_bcstnebf16_ps (&var);
50 if (check_union128 (dst_128, res_ref_128))
51 abort();
52 if (check_union256 (dst_256, res_ref_256))
53 abort();
54 }