xref: /aosp_15_r20/external/FP16/test/ieee-to-fp32x2-psimd.cc (revision 5f32b7105932ea8520a0e8811c640f936367d707)
1*5f32b710SXin Li #include <gtest/gtest.h>
2*5f32b710SXin Li 
3*5f32b710SXin Li #include <cstdint>
4*5f32b710SXin Li 
5*5f32b710SXin Li #include <fp16.h>
6*5f32b710SXin Li #include <fp16/psimd.h>
7*5f32b710SXin Li 
8*5f32b710SXin Li 
TEST(FP16_IEEE_TO_FP32x2_PSIMD,infinity)9*5f32b710SXin Li TEST(FP16_IEEE_TO_FP32x2_PSIMD, infinity) {
10*5f32b710SXin Li 	const uint16_t positive_infinity_f16 = UINT16_C(0x7C00);
11*5f32b710SXin Li 	const uint16_t negative_infinity_f16 = UINT16_C(0xFC00);
12*5f32b710SXin Li 
13*5f32b710SXin Li 	const uint32_t positive_infinity_f32 = UINT32_C(0x7F800000);
14*5f32b710SXin Li 	const uint32_t negative_infinity_f32 = UINT32_C(0xFF800000);
15*5f32b710SXin Li 
16*5f32b710SXin Li 	const psimd_u16 fp16 = {
17*5f32b710SXin Li 		positive_infinity_f16, negative_infinity_f16,
18*5f32b710SXin Li 		negative_infinity_f16, positive_infinity_f16,
19*5f32b710SXin Li 		positive_infinity_f16, positive_infinity_f16,
20*5f32b710SXin Li 		negative_infinity_f16, negative_infinity_f16
21*5f32b710SXin Li 	};
22*5f32b710SXin Li 	const psimd_u32x2 fp32 =
23*5f32b710SXin Li 		psimd_cast_f32x2_u32x2(fp16_ieee_to_fp32x2_psimd(fp16));
24*5f32b710SXin Li 
25*5f32b710SXin Li 	EXPECT_EQ(positive_infinity_f32, fp32.lo[0]) <<
26*5f32b710SXin Li 		std::hex << std::uppercase << std::setfill('0') <<
27*5f32b710SXin Li 		"F16 = 0x" << std::setw(4) << fp16[0] << ", " <<
28*5f32b710SXin Li 		"F32(F16) = 0x" << std::setw(8) << fp32.lo[0] << ", " <<
29*5f32b710SXin Li 		"F32 = 0x" << std::setw(8) << positive_infinity_f32;
30*5f32b710SXin Li 	EXPECT_EQ(negative_infinity_f32, fp32.lo[1]) <<
31*5f32b710SXin Li 		std::hex << std::uppercase << std::setfill('0') <<
32*5f32b710SXin Li 		"F16 = 0x" << std::setw(4) << fp16[1] << ", " <<
33*5f32b710SXin Li 		"F32(F16) = 0x" << std::setw(8) << fp32.lo[1] << ", " <<
34*5f32b710SXin Li 		"F32 = 0x" << std::setw(8) << negative_infinity_f32;
35*5f32b710SXin Li 	EXPECT_EQ(negative_infinity_f32, fp32.lo[2]) <<
36*5f32b710SXin Li 		std::hex << std::uppercase << std::setfill('0') <<
37*5f32b710SXin Li 		"F16 = 0x" << std::setw(4) << fp16[2] << ", " <<
38*5f32b710SXin Li 		"F32(F16) = 0x" << std::setw(8) << fp32.lo[2] << ", " <<
39*5f32b710SXin Li 		"F32 = 0x" << std::setw(8) << negative_infinity_f32;
40*5f32b710SXin Li 	EXPECT_EQ(positive_infinity_f32, fp32.lo[3]) <<
41*5f32b710SXin Li 		std::hex << std::uppercase << std::setfill('0') <<
42*5f32b710SXin Li 		"F16 = 0x" << std::setw(4) << fp16[3] << ", " <<
43*5f32b710SXin Li 		"F32(F16) = 0x" << std::setw(8) << fp32.lo[3] << ", " <<
44*5f32b710SXin Li 		"F32 = 0x" << std::setw(8) << positive_infinity_f32;
45*5f32b710SXin Li 	EXPECT_EQ(positive_infinity_f32, fp32.hi[0]) <<
46*5f32b710SXin Li 		std::hex << std::uppercase << std::setfill('0') <<
47*5f32b710SXin Li 		"F16 = 0x" << std::setw(4) << fp16[4] << ", " <<
48*5f32b710SXin Li 		"F32(F16) = 0x" << std::setw(8) << fp32.hi[0] << ", " <<
49*5f32b710SXin Li 		"F32 = 0x" << std::setw(8) << positive_infinity_f32;
50*5f32b710SXin Li 	EXPECT_EQ(positive_infinity_f32, fp32.hi[1]) <<
51*5f32b710SXin Li 		std::hex << std::uppercase << std::setfill('0') <<
52*5f32b710SXin Li 		"F16 = 0x" << std::setw(4) << fp16[5] << ", " <<
53*5f32b710SXin Li 		"F32(F16) = 0x" << std::setw(8) << fp32.hi[1] << ", " <<
54*5f32b710SXin Li 		"F32 = 0x" << std::setw(8) << positive_infinity_f32;
55*5f32b710SXin Li 	EXPECT_EQ(negative_infinity_f32, fp32.hi[2]) <<
56*5f32b710SXin Li 		std::hex << std::uppercase << std::setfill('0') <<
57*5f32b710SXin Li 		"F16 = 0x" << std::setw(4) << fp16[6] << ", " <<
58*5f32b710SXin Li 		"F32(F16) = 0x" << std::setw(8) << fp32.hi[2] << ", " <<
59*5f32b710SXin Li 		"F32 = 0x" << std::setw(8) << negative_infinity_f32;
60*5f32b710SXin Li 	EXPECT_EQ(negative_infinity_f32, fp32.hi[3]) <<
61*5f32b710SXin Li 		std::hex << std::uppercase << std::setfill('0') <<
62*5f32b710SXin Li 		"F16 = 0x" << std::setw(4) << fp16[7] << ", " <<
63*5f32b710SXin Li 		"F32(F16) = 0x" << std::setw(8) << fp32.hi[3] << ", " <<
64*5f32b710SXin Li 		"F32 = 0x" << std::setw(8) << negative_infinity_f32;
65*5f32b710SXin Li }
66*5f32b710SXin Li 
TEST(FP16_IEEE_TO_FP32x2_PSIMD,positive_nan)67*5f32b710SXin Li TEST(FP16_IEEE_TO_FP32x2_PSIMD, positive_nan) {
68*5f32b710SXin Li 	for (uint16_t h = 0; h < 0x0400; h += 8) {
69*5f32b710SXin Li 		const psimd_u16 fp16 = {
70*5f32b710SXin Li 			(uint16_t) (h + 0x7C00 + (h == 0)) /* Avoid infinity */,
71*5f32b710SXin Li 			(uint16_t) (h + 0x7C01),
72*5f32b710SXin Li 			(uint16_t) (h + 0x7C02),
73*5f32b710SXin Li 			(uint16_t) (h + 0x7C03),
74*5f32b710SXin Li 			(uint16_t) (h + 0x7C04),
75*5f32b710SXin Li 			(uint16_t) (h + 0x7C05),
76*5f32b710SXin Li 			(uint16_t) (h + 0x7C06),
77*5f32b710SXin Li 			(uint16_t) (h + 0x7C07),
78*5f32b710SXin Li 		};
79*5f32b710SXin Li 		const psimd_u32x2 fp32 =
80*5f32b710SXin Li 			psimd_cast_f32x2_u32x2(fp16_ieee_to_fp32x2_psimd(fp16));
81*5f32b710SXin Li 
82*5f32b710SXin Li 		/* Check sign */
83*5f32b710SXin Li 		EXPECT_EQ(fp32.lo[0] & UINT32_C(0x80000000), 0) <<
84*5f32b710SXin Li 			std::hex << std::uppercase << std::setfill('0') <<
85*5f32b710SXin Li 			"F16 = 0x" << std::setw(4) << fp16[0] << ", " <<
86*5f32b710SXin Li 			"F32(F16) = 0x" << std::setw(8) << fp32.lo[0];
87*5f32b710SXin Li 		EXPECT_EQ(fp32.lo[1] & UINT32_C(0x80000000), 0) <<
88*5f32b710SXin Li 			std::hex << std::uppercase << std::setfill('0') <<
89*5f32b710SXin Li 			"F16 = 0x" << std::setw(4) << fp16[1] << ", " <<
90*5f32b710SXin Li 			"F32(F16) = 0x" << std::setw(8) << fp32.lo[1];
91*5f32b710SXin Li 		EXPECT_EQ(fp32.lo[2] & UINT32_C(0x80000000), 0) <<
92*5f32b710SXin Li 			std::hex << std::uppercase << std::setfill('0') <<
93*5f32b710SXin Li 			"F16 = 0x" << std::setw(4) << fp16[2] << ", " <<
94*5f32b710SXin Li 			"F32(F16) = 0x" << std::setw(8) << fp32.lo[2];
95*5f32b710SXin Li 		EXPECT_EQ(fp32.lo[3] & UINT32_C(0x80000000), 0) <<
96*5f32b710SXin Li 			std::hex << std::uppercase << std::setfill('0') <<
97*5f32b710SXin Li 			"F16 = 0x" << std::setw(4) << fp16[3] << ", " <<
98*5f32b710SXin Li 			"F32(F16) = 0x" << std::setw(8) << fp32.lo[3];
99*5f32b710SXin Li 		EXPECT_EQ(fp32.hi[0] & UINT32_C(0x80000000), 0) <<
100*5f32b710SXin Li 			std::hex << std::uppercase << std::setfill('0') <<
101*5f32b710SXin Li 			"F16 = 0x" << std::setw(4) << fp16[4] << ", " <<
102*5f32b710SXin Li 			"F32(F16) = 0x" << std::setw(8) << fp32.hi[0];
103*5f32b710SXin Li 		EXPECT_EQ(fp32.hi[1] & UINT32_C(0x80000000), 0) <<
104*5f32b710SXin Li 			std::hex << std::uppercase << std::setfill('0') <<
105*5f32b710SXin Li 			"F16 = 0x" << std::setw(4) << fp16[5] << ", " <<
106*5f32b710SXin Li 			"F32(F16) = 0x" << std::setw(8) << fp32.hi[1];
107*5f32b710SXin Li 		EXPECT_EQ(fp32.hi[2] & UINT32_C(0x80000000), 0) <<
108*5f32b710SXin Li 			std::hex << std::uppercase << std::setfill('0') <<
109*5f32b710SXin Li 			"F16 = 0x" << std::setw(4) << fp16[6] << ", " <<
110*5f32b710SXin Li 			"F32(F16) = 0x" << std::setw(8) << fp32.hi[2];
111*5f32b710SXin Li 		EXPECT_EQ(fp32.hi[3] & UINT32_C(0x80000000), 0) <<
112*5f32b710SXin Li 			std::hex << std::uppercase << std::setfill('0') <<
113*5f32b710SXin Li 			"F16 = 0x" << std::setw(4) << fp16[7] << ", " <<
114*5f32b710SXin Li 			"F32(F16) = 0x" << std::setw(8) << fp32.hi[3];
115*5f32b710SXin Li 
116*5f32b710SXin Li 		/* Check exponent */
117*5f32b710SXin Li 		EXPECT_EQ(fp32.lo[0] & UINT32_C(0x7F800000), UINT32_C(0x7F800000)) <<
118*5f32b710SXin Li 			std::hex << std::uppercase << std::setfill('0') <<
119*5f32b710SXin Li 			"F16 = 0x" << std::setw(4) << fp16[0] << ", " <<
120*5f32b710SXin Li 			"F32(F16) = 0x" << std::setw(8) << fp32.lo[0];
121*5f32b710SXin Li 		EXPECT_EQ(fp32.lo[1] & UINT32_C(0x7F800000), UINT32_C(0x7F800000)) <<
122*5f32b710SXin Li 			std::hex << std::uppercase << std::setfill('0') <<
123*5f32b710SXin Li 			"F16 = 0x" << std::setw(4) << fp16[1] << ", " <<
124*5f32b710SXin Li 			"F32(F16) = 0x" << std::setw(8) << fp32.lo[1];
125*5f32b710SXin Li 		EXPECT_EQ(fp32.lo[2] & UINT32_C(0x7F800000), UINT32_C(0x7F800000)) <<
126*5f32b710SXin Li 			std::hex << std::uppercase << std::setfill('0') <<
127*5f32b710SXin Li 			"F16 = 0x" << std::setw(4) << fp16[2] << ", " <<
128*5f32b710SXin Li 			"F32(F16) = 0x" << std::setw(8) << fp32.lo[2];
129*5f32b710SXin Li 		EXPECT_EQ(fp32.lo[3] & UINT32_C(0x7F800000), UINT32_C(0x7F800000)) <<
130*5f32b710SXin Li 			std::hex << std::uppercase << std::setfill('0') <<
131*5f32b710SXin Li 			"F16 = 0x" << std::setw(4) << fp16[3] << ", " <<
132*5f32b710SXin Li 			"F32(F16) = 0x" << std::setw(8) << fp32.lo[3];
133*5f32b710SXin Li 		EXPECT_EQ(fp32.hi[0] & UINT32_C(0x7F800000), UINT32_C(0x7F800000)) <<
134*5f32b710SXin Li 			std::hex << std::uppercase << std::setfill('0') <<
135*5f32b710SXin Li 			"F16 = 0x" << std::setw(4) << fp16[4] << ", " <<
136*5f32b710SXin Li 			"F32(F16) = 0x" << std::setw(8) << fp32.hi[0];
137*5f32b710SXin Li 		EXPECT_EQ(fp32.hi[1] & UINT32_C(0x7F800000), UINT32_C(0x7F800000)) <<
138*5f32b710SXin Li 			std::hex << std::uppercase << std::setfill('0') <<
139*5f32b710SXin Li 			"F16 = 0x" << std::setw(4) << fp16[5] << ", " <<
140*5f32b710SXin Li 			"F32(F16) = 0x" << std::setw(8) << fp32.hi[1];
141*5f32b710SXin Li 		EXPECT_EQ(fp32.hi[2] & UINT32_C(0x7F800000), UINT32_C(0x7F800000)) <<
142*5f32b710SXin Li 			std::hex << std::uppercase << std::setfill('0') <<
143*5f32b710SXin Li 			"F16 = 0x" << std::setw(4) << fp16[6] << ", " <<
144*5f32b710SXin Li 			"F32(F16) = 0x" << std::setw(8) << fp32.hi[2];
145*5f32b710SXin Li 		EXPECT_EQ(fp32.hi[3] & UINT32_C(0x7F800000), UINT32_C(0x7F800000)) <<
146*5f32b710SXin Li 			std::hex << std::uppercase << std::setfill('0') <<
147*5f32b710SXin Li 			"F16 = 0x" << std::setw(4) << fp16[7] << ", " <<
148*5f32b710SXin Li 			"F32(F16) = 0x" << std::setw(8) << fp32.hi[3];
149*5f32b710SXin Li 
150*5f32b710SXin Li 		/* Check mantissa */
151*5f32b710SXin Li 		EXPECT_NE(fp32.lo[0] & UINT32_C(0x007FFFFF), UINT32_C(0)) <<
152*5f32b710SXin Li 			std::hex << std::uppercase << std::setfill('0') <<
153*5f32b710SXin Li 			"F16 = 0x" << std::setw(4) << fp16[0] << ", " <<
154*5f32b710SXin Li 			"F32(F16) = 0x" << std::setw(8) << fp32.lo[0];
155*5f32b710SXin Li 		EXPECT_NE(fp32.lo[1] & UINT32_C(0x007FFFFF), UINT32_C(0)) <<
156*5f32b710SXin Li 			std::hex << std::uppercase << std::setfill('0') <<
157*5f32b710SXin Li 			"F16 = 0x" << std::setw(4) << fp16[1] << ", " <<
158*5f32b710SXin Li 			"F32(F16) = 0x" << std::setw(8) << fp32.lo[1];
159*5f32b710SXin Li 		EXPECT_NE(fp32.lo[2] & UINT32_C(0x007FFFFF), UINT32_C(0)) <<
160*5f32b710SXin Li 			std::hex << std::uppercase << std::setfill('0') <<
161*5f32b710SXin Li 			"F16 = 0x" << std::setw(4) << fp16[2] << ", " <<
162*5f32b710SXin Li 			"F32(F16) = 0x" << std::setw(8) << fp32.lo[2];
163*5f32b710SXin Li 		EXPECT_NE(fp32.lo[3] & UINT32_C(0x007FFFFF), UINT32_C(0)) <<
164*5f32b710SXin Li 			std::hex << std::uppercase << std::setfill('0') <<
165*5f32b710SXin Li 			"F16 = 0x" << std::setw(4) << fp16[3] << ", " <<
166*5f32b710SXin Li 			"F32(F16) = 0x" << std::setw(8) << fp32.lo[3];
167*5f32b710SXin Li 		EXPECT_NE(fp32.hi[0] & UINT32_C(0x007FFFFF), UINT32_C(0)) <<
168*5f32b710SXin Li 			std::hex << std::uppercase << std::setfill('0') <<
169*5f32b710SXin Li 			"F16 = 0x" << std::setw(4) << fp16[4] << ", " <<
170*5f32b710SXin Li 			"F32(F16) = 0x" << std::setw(8) << fp32.hi[0];
171*5f32b710SXin Li 		EXPECT_NE(fp32.hi[1] & UINT32_C(0x007FFFFF), UINT32_C(0)) <<
172*5f32b710SXin Li 			std::hex << std::uppercase << std::setfill('0') <<
173*5f32b710SXin Li 			"F16 = 0x" << std::setw(4) << fp16[5] << ", " <<
174*5f32b710SXin Li 			"F32(F16) = 0x" << std::setw(8) << fp32.hi[1];
175*5f32b710SXin Li 		EXPECT_NE(fp32.hi[2] & UINT32_C(0x007FFFFF), UINT32_C(0)) <<
176*5f32b710SXin Li 			std::hex << std::uppercase << std::setfill('0') <<
177*5f32b710SXin Li 			"F16 = 0x" << std::setw(4) << fp16[6] << ", " <<
178*5f32b710SXin Li 			"F32(F16) = 0x" << std::setw(8) << fp32.hi[2];
179*5f32b710SXin Li 		EXPECT_NE(fp32.hi[3] & UINT32_C(0x007FFFFF), UINT32_C(0)) <<
180*5f32b710SXin Li 			std::hex << std::uppercase << std::setfill('0') <<
181*5f32b710SXin Li 			"F16 = 0x" << std::setw(4) << fp16[7] << ", " <<
182*5f32b710SXin Li 			"F32(F16) = 0x" << std::setw(8) << fp32.hi[3];
183*5f32b710SXin Li 	}
184*5f32b710SXin Li }
185*5f32b710SXin Li 
TEST(FP16_IEEE_TO_FP32x2_PSIMD,negative_nan)186*5f32b710SXin Li TEST(FP16_IEEE_TO_FP32x2_PSIMD, negative_nan) {
187*5f32b710SXin Li 	for (uint16_t h = 0; h < 0x0400; h += 8) {
188*5f32b710SXin Li 		const psimd_u16 fp16 = {
189*5f32b710SXin Li 			(uint16_t) (h + 0xFC00 + (h == 0)) /* Avoid infinity */,
190*5f32b710SXin Li 			(uint16_t) (h + 0xFC01),
191*5f32b710SXin Li 			(uint16_t) (h + 0xFC02),
192*5f32b710SXin Li 			(uint16_t) (h + 0xFC03),
193*5f32b710SXin Li 			(uint16_t) (h + 0xFC04),
194*5f32b710SXin Li 			(uint16_t) (h + 0xFC05),
195*5f32b710SXin Li 			(uint16_t) (h + 0xFC06),
196*5f32b710SXin Li 			(uint16_t) (h + 0xFC07),
197*5f32b710SXin Li 		};
198*5f32b710SXin Li 		const psimd_u32x2 fp32 =
199*5f32b710SXin Li 			psimd_cast_f32x2_u32x2(fp16_ieee_to_fp32x2_psimd(fp16));
200*5f32b710SXin Li 
201*5f32b710SXin Li 		/* Check sign */
202*5f32b710SXin Li 		EXPECT_EQ(fp32.lo[0] & UINT32_C(0x80000000), UINT32_C(0x80000000)) <<
203*5f32b710SXin Li 			std::hex << std::uppercase << std::setfill('0') <<
204*5f32b710SXin Li 			"F16 = 0x" << std::setw(4) << fp16[0] << ", " <<
205*5f32b710SXin Li 			"F32(F16) = 0x" << std::setw(8) << fp32.lo[0];
206*5f32b710SXin Li 		EXPECT_EQ(fp32.lo[1] & UINT32_C(0x80000000), UINT32_C(0x80000000)) <<
207*5f32b710SXin Li 			std::hex << std::uppercase << std::setfill('0') <<
208*5f32b710SXin Li 			"F16 = 0x" << std::setw(4) << fp16[1] << ", " <<
209*5f32b710SXin Li 			"F32(F16) = 0x" << std::setw(8) << fp32.lo[1];
210*5f32b710SXin Li 		EXPECT_EQ(fp32.lo[2] & UINT32_C(0x80000000), UINT32_C(0x80000000)) <<
211*5f32b710SXin Li 			std::hex << std::uppercase << std::setfill('0') <<
212*5f32b710SXin Li 			"F16 = 0x" << std::setw(4) << fp16[2] << ", " <<
213*5f32b710SXin Li 			"F32(F16) = 0x" << std::setw(8) << fp32.lo[2];
214*5f32b710SXin Li 		EXPECT_EQ(fp32.lo[3] & UINT32_C(0x80000000), UINT32_C(0x80000000)) <<
215*5f32b710SXin Li 			std::hex << std::uppercase << std::setfill('0') <<
216*5f32b710SXin Li 			"F16 = 0x" << std::setw(4) << fp16[3] << ", " <<
217*5f32b710SXin Li 			"F32(F16) = 0x" << std::setw(8) << fp32.lo[3];
218*5f32b710SXin Li 		EXPECT_EQ(fp32.hi[0] & UINT32_C(0x80000000), UINT32_C(0x80000000)) <<
219*5f32b710SXin Li 			std::hex << std::uppercase << std::setfill('0') <<
220*5f32b710SXin Li 			"F16 = 0x" << std::setw(4) << fp16[4] << ", " <<
221*5f32b710SXin Li 			"F32(F16) = 0x" << std::setw(8) << fp32.hi[0];
222*5f32b710SXin Li 		EXPECT_EQ(fp32.hi[1] & UINT32_C(0x80000000), UINT32_C(0x80000000)) <<
223*5f32b710SXin Li 			std::hex << std::uppercase << std::setfill('0') <<
224*5f32b710SXin Li 			"F16 = 0x" << std::setw(4) << fp16[5] << ", " <<
225*5f32b710SXin Li 			"F32(F16) = 0x" << std::setw(8) << fp32.hi[1];
226*5f32b710SXin Li 		EXPECT_EQ(fp32.hi[2] & UINT32_C(0x80000000), UINT32_C(0x80000000)) <<
227*5f32b710SXin Li 			std::hex << std::uppercase << std::setfill('0') <<
228*5f32b710SXin Li 			"F16 = 0x" << std::setw(4) << fp16[6] << ", " <<
229*5f32b710SXin Li 			"F32(F16) = 0x" << std::setw(8) << fp32.hi[2];
230*5f32b710SXin Li 		EXPECT_EQ(fp32.hi[3] & UINT32_C(0x80000000), UINT32_C(0x80000000)) <<
231*5f32b710SXin Li 			std::hex << std::uppercase << std::setfill('0') <<
232*5f32b710SXin Li 			"F16 = 0x" << std::setw(4) << fp16[7] << ", " <<
233*5f32b710SXin Li 			"F32(F16) = 0x" << std::setw(8) << fp32.hi[3];
234*5f32b710SXin Li 
235*5f32b710SXin Li 		/* Check exponent */
236*5f32b710SXin Li 		EXPECT_EQ(fp32.lo[0] & UINT32_C(0x7F800000), UINT32_C(0x7F800000)) <<
237*5f32b710SXin Li 			std::hex << std::uppercase << std::setfill('0') <<
238*5f32b710SXin Li 			"F16 = 0x" << std::setw(4) << fp16[0] << ", " <<
239*5f32b710SXin Li 			"F32(F16) = 0x" << std::setw(8) << fp32.lo[0];
240*5f32b710SXin Li 		EXPECT_EQ(fp32.lo[1] & UINT32_C(0x7F800000), UINT32_C(0x7F800000)) <<
241*5f32b710SXin Li 			std::hex << std::uppercase << std::setfill('0') <<
242*5f32b710SXin Li 			"F16 = 0x" << std::setw(4) << fp16[1] << ", " <<
243*5f32b710SXin Li 			"F32(F16) = 0x" << std::setw(8) << fp32.lo[1];
244*5f32b710SXin Li 		EXPECT_EQ(fp32.lo[2] & UINT32_C(0x7F800000), UINT32_C(0x7F800000)) <<
245*5f32b710SXin Li 			std::hex << std::uppercase << std::setfill('0') <<
246*5f32b710SXin Li 			"F16 = 0x" << std::setw(4) << fp16[2] << ", " <<
247*5f32b710SXin Li 			"F32(F16) = 0x" << std::setw(8) << fp32.lo[2];
248*5f32b710SXin Li 		EXPECT_EQ(fp32.lo[3] & UINT32_C(0x7F800000), UINT32_C(0x7F800000)) <<
249*5f32b710SXin Li 			std::hex << std::uppercase << std::setfill('0') <<
250*5f32b710SXin Li 			"F16 = 0x" << std::setw(4) << fp16[3] << ", " <<
251*5f32b710SXin Li 			"F32(F16) = 0x" << std::setw(8) << fp32.lo[3];
252*5f32b710SXin Li 		EXPECT_EQ(fp32.hi[0] & UINT32_C(0x7F800000), UINT32_C(0x7F800000)) <<
253*5f32b710SXin Li 			std::hex << std::uppercase << std::setfill('0') <<
254*5f32b710SXin Li 			"F16 = 0x" << std::setw(4) << fp16[4] << ", " <<
255*5f32b710SXin Li 			"F32(F16) = 0x" << std::setw(8) << fp32.hi[0];
256*5f32b710SXin Li 		EXPECT_EQ(fp32.hi[1] & UINT32_C(0x7F800000), UINT32_C(0x7F800000)) <<
257*5f32b710SXin Li 			std::hex << std::uppercase << std::setfill('0') <<
258*5f32b710SXin Li 			"F16 = 0x" << std::setw(4) << fp16[5] << ", " <<
259*5f32b710SXin Li 			"F32(F16) = 0x" << std::setw(8) << fp32.hi[1];
260*5f32b710SXin Li 		EXPECT_EQ(fp32.hi[2] & UINT32_C(0x7F800000), UINT32_C(0x7F800000)) <<
261*5f32b710SXin Li 			std::hex << std::uppercase << std::setfill('0') <<
262*5f32b710SXin Li 			"F16 = 0x" << std::setw(4) << fp16[6] << ", " <<
263*5f32b710SXin Li 			"F32(F16) = 0x" << std::setw(8) << fp32.hi[2];
264*5f32b710SXin Li 		EXPECT_EQ(fp32.hi[3] & UINT32_C(0x7F800000), UINT32_C(0x7F800000)) <<
265*5f32b710SXin Li 			std::hex << std::uppercase << std::setfill('0') <<
266*5f32b710SXin Li 			"F16 = 0x" << std::setw(4) << fp16[7] << ", " <<
267*5f32b710SXin Li 			"F32(F16) = 0x" << std::setw(8) << fp32.hi[3];
268*5f32b710SXin Li 
269*5f32b710SXin Li 		/* Check mantissa */
270*5f32b710SXin Li 		EXPECT_NE(fp32.lo[0] & UINT32_C(0x007FFFFF), UINT32_C(0)) <<
271*5f32b710SXin Li 			std::hex << std::uppercase << std::setfill('0') <<
272*5f32b710SXin Li 			"F16 = 0x" << std::setw(4) << fp16[0] << ", " <<
273*5f32b710SXin Li 			"F32(F16) = 0x" << std::setw(8) << fp32.lo[0];
274*5f32b710SXin Li 		EXPECT_NE(fp32.lo[1] & UINT32_C(0x007FFFFF), UINT32_C(0)) <<
275*5f32b710SXin Li 			std::hex << std::uppercase << std::setfill('0') <<
276*5f32b710SXin Li 			"F16 = 0x" << std::setw(4) << fp16[1] << ", " <<
277*5f32b710SXin Li 			"F32(F16) = 0x" << std::setw(8) << fp32.lo[1];
278*5f32b710SXin Li 		EXPECT_NE(fp32.lo[2] & UINT32_C(0x007FFFFF), UINT32_C(0)) <<
279*5f32b710SXin Li 			std::hex << std::uppercase << std::setfill('0') <<
280*5f32b710SXin Li 			"F16 = 0x" << std::setw(4) << fp16[2] << ", " <<
281*5f32b710SXin Li 			"F32(F16) = 0x" << std::setw(8) << fp32.lo[2];
282*5f32b710SXin Li 		EXPECT_NE(fp32.lo[3] & UINT32_C(0x007FFFFF), UINT32_C(0)) <<
283*5f32b710SXin Li 			std::hex << std::uppercase << std::setfill('0') <<
284*5f32b710SXin Li 			"F16 = 0x" << std::setw(4) << fp16[3] << ", " <<
285*5f32b710SXin Li 			"F32(F16) = 0x" << std::setw(8) << fp32.lo[3];
286*5f32b710SXin Li 		EXPECT_NE(fp32.hi[0] & UINT32_C(0x007FFFFF), UINT32_C(0)) <<
287*5f32b710SXin Li 			std::hex << std::uppercase << std::setfill('0') <<
288*5f32b710SXin Li 			"F16 = 0x" << std::setw(4) << fp16[4] << ", " <<
289*5f32b710SXin Li 			"F32(F16) = 0x" << std::setw(8) << fp32.hi[0];
290*5f32b710SXin Li 		EXPECT_NE(fp32.hi[1] & UINT32_C(0x007FFFFF), UINT32_C(0)) <<
291*5f32b710SXin Li 			std::hex << std::uppercase << std::setfill('0') <<
292*5f32b710SXin Li 			"F16 = 0x" << std::setw(4) << fp16[5] << ", " <<
293*5f32b710SXin Li 			"F32(F16) = 0x" << std::setw(8) << fp32.hi[1];
294*5f32b710SXin Li 		EXPECT_NE(fp32.hi[2] & UINT32_C(0x007FFFFF), UINT32_C(0)) <<
295*5f32b710SXin Li 			std::hex << std::uppercase << std::setfill('0') <<
296*5f32b710SXin Li 			"F16 = 0x" << std::setw(4) << fp16[6] << ", " <<
297*5f32b710SXin Li 			"F32(F16) = 0x" << std::setw(8) << fp32.hi[2];
298*5f32b710SXin Li 		EXPECT_NE(fp32.hi[3] & UINT32_C(0x007FFFFF), UINT32_C(0)) <<
299*5f32b710SXin Li 			std::hex << std::uppercase << std::setfill('0') <<
300*5f32b710SXin Li 			"F16 = 0x" << std::setw(4) << fp16[7] << ", " <<
301*5f32b710SXin Li 			"F32(F16) = 0x" << std::setw(8) << fp32.hi[3];
302*5f32b710SXin Li 	}
303*5f32b710SXin Li }
304*5f32b710SXin Li 
TEST(FP16_IEEE_TO_FP32x2_PSIMD,positive_normalized_values)305*5f32b710SXin Li TEST(FP16_IEEE_TO_FP32x2_PSIMD, positive_normalized_values) {
306*5f32b710SXin Li 	const uint32_t exponentBias = 15;
307*5f32b710SXin Li 	for (int32_t e = -14; e <= 15; e++) {
308*5f32b710SXin Li 		for (uint16_t h = 0; h < 0x0400; h += 8) {
309*5f32b710SXin Li 			const psimd_u16 fp16 = {
310*5f32b710SXin Li 				(uint16_t) (h + ((e + exponentBias) << 10) + 0),
311*5f32b710SXin Li 				(uint16_t) (h + ((e + exponentBias) << 10) + 1),
312*5f32b710SXin Li 				(uint16_t) (h + ((e + exponentBias) << 10) + 2),
313*5f32b710SXin Li 				(uint16_t) (h + ((e + exponentBias) << 10) + 3),
314*5f32b710SXin Li 				(uint16_t) (h + ((e + exponentBias) << 10) + 4),
315*5f32b710SXin Li 				(uint16_t) (h + ((e + exponentBias) << 10) + 5),
316*5f32b710SXin Li 				(uint16_t) (h + ((e + exponentBias) << 10) + 6),
317*5f32b710SXin Li 				(uint16_t) (h + ((e + exponentBias) << 10) + 7)
318*5f32b710SXin Li 			};
319*5f32b710SXin Li 			const psimd_u32x2 fp32 =
320*5f32b710SXin Li 				psimd_cast_f32x2_u32x2(fp16_ieee_to_fp32x2_psimd(fp16));
321*5f32b710SXin Li 
322*5f32b710SXin Li 			EXPECT_EQ(fp16_ieee_to_fp32_bits(fp16[0]), fp32.lo[0]) <<
323*5f32b710SXin Li 				std::hex << std::uppercase << std::setfill('0') <<
324*5f32b710SXin Li 				"F16 = 0x" << std::setw(4) << fp16[0] << ", " <<
325*5f32b710SXin Li 				"F32(F16) = 0x" << std::setw(8) << fp32.lo[0] << ", " <<
326*5f32b710SXin Li 				"F32 = 0x" << std::setw(8) << fp16_ieee_to_fp32_bits(fp16[0]);
327*5f32b710SXin Li 			EXPECT_EQ(fp16_ieee_to_fp32_bits(fp16[1]), fp32.lo[1]) <<
328*5f32b710SXin Li 				std::hex << std::uppercase << std::setfill('0') <<
329*5f32b710SXin Li 				"F16 = 0x" << std::setw(4) << fp16[1] << ", " <<
330*5f32b710SXin Li 				"F32(F16) = 0x" << std::setw(8) << fp32.lo[1] << ", " <<
331*5f32b710SXin Li 				"F32 = 0x" << std::setw(8) << fp16_ieee_to_fp32_bits(fp16[1]);
332*5f32b710SXin Li 			EXPECT_EQ(fp16_ieee_to_fp32_bits(fp16[2]), fp32.lo[2]) <<
333*5f32b710SXin Li 				std::hex << std::uppercase << std::setfill('0') <<
334*5f32b710SXin Li 				"F16 = 0x" << std::setw(4) << fp16[2] << ", " <<
335*5f32b710SXin Li 				"F32(F16) = 0x" << std::setw(8) << fp32.lo[2] << ", " <<
336*5f32b710SXin Li 				"F32 = 0x" << std::setw(8) << fp16_ieee_to_fp32_bits(fp16[2]);
337*5f32b710SXin Li 			EXPECT_EQ(fp16_ieee_to_fp32_bits(fp16[3]), fp32.lo[3]) <<
338*5f32b710SXin Li 				std::hex << std::uppercase << std::setfill('0') <<
339*5f32b710SXin Li 				"F16 = 0x" << std::setw(4) << fp16[3] << ", " <<
340*5f32b710SXin Li 				"F32(F16) = 0x" << std::setw(8) << fp32.lo[3] << ", " <<
341*5f32b710SXin Li 				"F32 = 0x" << std::setw(8) << fp16_ieee_to_fp32_bits(fp16[3]);
342*5f32b710SXin Li 			EXPECT_EQ(fp16_ieee_to_fp32_bits(fp16[4]), fp32.hi[0]) <<
343*5f32b710SXin Li 				std::hex << std::uppercase << std::setfill('0') <<
344*5f32b710SXin Li 				"F16 = 0x" << std::setw(4) << fp16[4] << ", " <<
345*5f32b710SXin Li 				"F32(F16) = 0x" << std::setw(8) << fp32.hi[0] << ", " <<
346*5f32b710SXin Li 				"F32 = 0x" << std::setw(8) << fp16_ieee_to_fp32_bits(fp16[4]);
347*5f32b710SXin Li 			EXPECT_EQ(fp16_ieee_to_fp32_bits(fp16[5]), fp32.hi[1]) <<
348*5f32b710SXin Li 				std::hex << std::uppercase << std::setfill('0') <<
349*5f32b710SXin Li 				"F16 = 0x" << std::setw(4) << fp16[5] << ", " <<
350*5f32b710SXin Li 				"F32(F16) = 0x" << std::setw(8) << fp32.hi[1] << ", " <<
351*5f32b710SXin Li 				"F32 = 0x" << std::setw(8) << fp16_ieee_to_fp32_bits(fp16[5]);
352*5f32b710SXin Li 			EXPECT_EQ(fp16_ieee_to_fp32_bits(fp16[6]), fp32.hi[2]) <<
353*5f32b710SXin Li 				std::hex << std::uppercase << std::setfill('0') <<
354*5f32b710SXin Li 				"F16 = 0x" << std::setw(4) << fp16[6] << ", " <<
355*5f32b710SXin Li 				"F32(F16) = 0x" << std::setw(8) << fp32.hi[2] << ", " <<
356*5f32b710SXin Li 				"F32 = 0x" << std::setw(8) << fp16_ieee_to_fp32_bits(fp16[6]);
357*5f32b710SXin Li 			EXPECT_EQ(fp16_ieee_to_fp32_bits(fp16[7]), fp32.hi[3]) <<
358*5f32b710SXin Li 				std::hex << std::uppercase << std::setfill('0') <<
359*5f32b710SXin Li 				"F16 = 0x" << std::setw(4) << fp16[7] << ", " <<
360*5f32b710SXin Li 				"F32(F16) = 0x" << std::setw(8) << fp32.hi[3] << ", " <<
361*5f32b710SXin Li 				"F32 = 0x" << std::setw(8) << fp16_ieee_to_fp32_bits(fp16[7]);
362*5f32b710SXin Li 		}
363*5f32b710SXin Li 	}
364*5f32b710SXin Li }
365*5f32b710SXin Li 
TEST(FP16_IEEE_TO_FP32x2_PSIMD,negative_normalized_values)366*5f32b710SXin Li TEST(FP16_IEEE_TO_FP32x2_PSIMD, negative_normalized_values) {
367*5f32b710SXin Li 	const uint32_t exponentBias = 15;
368*5f32b710SXin Li 	for (int32_t e = -14; e <= 15; e++) {
369*5f32b710SXin Li 		for (uint16_t h = 0; h < 0x0400; h += 8) {
370*5f32b710SXin Li 			const psimd_u16 fp16 = {
371*5f32b710SXin Li 				(uint16_t) (h + ((e + exponentBias) << 10) + 0x8000),
372*5f32b710SXin Li 				(uint16_t) (h + ((e + exponentBias) << 10) + 0x8001),
373*5f32b710SXin Li 				(uint16_t) (h + ((e + exponentBias) << 10) + 0x8002),
374*5f32b710SXin Li 				(uint16_t) (h + ((e + exponentBias) << 10) + 0x8003),
375*5f32b710SXin Li 				(uint16_t) (h + ((e + exponentBias) << 10) + 0x8004),
376*5f32b710SXin Li 				(uint16_t) (h + ((e + exponentBias) << 10) + 0x8005),
377*5f32b710SXin Li 				(uint16_t) (h + ((e + exponentBias) << 10) + 0x8006),
378*5f32b710SXin Li 				(uint16_t) (h + ((e + exponentBias) << 10) + 0x8007)
379*5f32b710SXin Li 			};
380*5f32b710SXin Li 			const psimd_u32x2 fp32 =
381*5f32b710SXin Li 				psimd_cast_f32x2_u32x2(fp16_ieee_to_fp32x2_psimd(fp16));
382*5f32b710SXin Li 
383*5f32b710SXin Li 			EXPECT_EQ(fp16_ieee_to_fp32_bits(fp16[0]), fp32.lo[0]) <<
384*5f32b710SXin Li 				std::hex << std::uppercase << std::setfill('0') <<
385*5f32b710SXin Li 				"F16 = 0x" << std::setw(4) << fp16[0] << ", " <<
386*5f32b710SXin Li 				"F32(F16) = 0x" << std::setw(8) << fp32.lo[0] << ", " <<
387*5f32b710SXin Li 				"F32 = 0x" << std::setw(8) << fp16_ieee_to_fp32_bits(fp16[0]);
388*5f32b710SXin Li 			EXPECT_EQ(fp16_ieee_to_fp32_bits(fp16[1]), fp32.lo[1]) <<
389*5f32b710SXin Li 				std::hex << std::uppercase << std::setfill('0') <<
390*5f32b710SXin Li 				"F16 = 0x" << std::setw(4) << fp16[1] << ", " <<
391*5f32b710SXin Li 				"F32(F16) = 0x" << std::setw(8) << fp32.lo[1] << ", " <<
392*5f32b710SXin Li 				"F32 = 0x" << std::setw(8) << fp16_ieee_to_fp32_bits(fp16[1]);
393*5f32b710SXin Li 			EXPECT_EQ(fp16_ieee_to_fp32_bits(fp16[2]), fp32.lo[2]) <<
394*5f32b710SXin Li 				std::hex << std::uppercase << std::setfill('0') <<
395*5f32b710SXin Li 				"F16 = 0x" << std::setw(4) << fp16[2] << ", " <<
396*5f32b710SXin Li 				"F32(F16) = 0x" << std::setw(8) << fp32.lo[2] << ", " <<
397*5f32b710SXin Li 				"F32 = 0x" << std::setw(8) << fp16_ieee_to_fp32_bits(fp16[2]);
398*5f32b710SXin Li 			EXPECT_EQ(fp16_ieee_to_fp32_bits(fp16[3]), fp32.lo[3]) <<
399*5f32b710SXin Li 				std::hex << std::uppercase << std::setfill('0') <<
400*5f32b710SXin Li 				"F16 = 0x" << std::setw(4) << fp16[3] << ", " <<
401*5f32b710SXin Li 				"F32(F16) = 0x" << std::setw(8) << fp32.lo[3] << ", " <<
402*5f32b710SXin Li 				"F32 = 0x" << std::setw(8) << fp16_ieee_to_fp32_bits(fp16[3]);
403*5f32b710SXin Li 			EXPECT_EQ(fp16_ieee_to_fp32_bits(fp16[4]), fp32.hi[0]) <<
404*5f32b710SXin Li 				std::hex << std::uppercase << std::setfill('0') <<
405*5f32b710SXin Li 				"F16 = 0x" << std::setw(4) << fp16[4] << ", " <<
406*5f32b710SXin Li 				"F32(F16) = 0x" << std::setw(8) << fp32.hi[0] << ", " <<
407*5f32b710SXin Li 				"F32 = 0x" << std::setw(8) << fp16_ieee_to_fp32_bits(fp16[4]);
408*5f32b710SXin Li 			EXPECT_EQ(fp16_ieee_to_fp32_bits(fp16[5]), fp32.hi[1]) <<
409*5f32b710SXin Li 				std::hex << std::uppercase << std::setfill('0') <<
410*5f32b710SXin Li 				"F16 = 0x" << std::setw(4) << fp16[5] << ", " <<
411*5f32b710SXin Li 				"F32(F16) = 0x" << std::setw(8) << fp32.hi[1] << ", " <<
412*5f32b710SXin Li 				"F32 = 0x" << std::setw(8) << fp16_ieee_to_fp32_bits(fp16[5]);
413*5f32b710SXin Li 			EXPECT_EQ(fp16_ieee_to_fp32_bits(fp16[6]), fp32.hi[2]) <<
414*5f32b710SXin Li 				std::hex << std::uppercase << std::setfill('0') <<
415*5f32b710SXin Li 				"F16 = 0x" << std::setw(4) << fp16[6] << ", " <<
416*5f32b710SXin Li 				"F32(F16) = 0x" << std::setw(8) << fp32.hi[2] << ", " <<
417*5f32b710SXin Li 				"F32 = 0x" << std::setw(8) << fp16_ieee_to_fp32_bits(fp16[6]);
418*5f32b710SXin Li 			EXPECT_EQ(fp16_ieee_to_fp32_bits(fp16[7]), fp32.hi[3]) <<
419*5f32b710SXin Li 				std::hex << std::uppercase << std::setfill('0') <<
420*5f32b710SXin Li 				"F16 = 0x" << std::setw(4) << fp16[7] << ", " <<
421*5f32b710SXin Li 				"F32(F16) = 0x" << std::setw(8) << fp32.hi[3] << ", " <<
422*5f32b710SXin Li 				"F32 = 0x" << std::setw(8) << fp16_ieee_to_fp32_bits(fp16[7]);
423*5f32b710SXin Li 		}
424*5f32b710SXin Li 	}
425*5f32b710SXin Li }
426*5f32b710SXin Li 
TEST(FP16_IEEE_TO_FP32x2_PSIMD,positive_denormalized_values)427*5f32b710SXin Li TEST(FP16_IEEE_TO_FP32x2_PSIMD, positive_denormalized_values) {
428*5f32b710SXin Li 	for (uint16_t h = 0; h < 0x0400; h += 8) {
429*5f32b710SXin Li 		const psimd_u16 fp16 = {
430*5f32b710SXin Li 			(uint16_t) (h + 0),
431*5f32b710SXin Li 			(uint16_t) (h + 1),
432*5f32b710SXin Li 			(uint16_t) (h + 2),
433*5f32b710SXin Li 			(uint16_t) (h + 3),
434*5f32b710SXin Li 			(uint16_t) (h + 4),
435*5f32b710SXin Li 			(uint16_t) (h + 5),
436*5f32b710SXin Li 			(uint16_t) (h + 6),
437*5f32b710SXin Li 			(uint16_t) (h + 7)
438*5f32b710SXin Li 		};
439*5f32b710SXin Li 		const psimd_u32x2 fp32 =
440*5f32b710SXin Li 			psimd_cast_f32x2_u32x2(fp16_ieee_to_fp32x2_psimd(fp16));
441*5f32b710SXin Li 
442*5f32b710SXin Li 		EXPECT_EQ(fp16_ieee_to_fp32_bits(fp16[0]), fp32.lo[0]) <<
443*5f32b710SXin Li 			std::hex << std::uppercase << std::setfill('0') <<
444*5f32b710SXin Li 			"F16 = 0x" << std::setw(4) << fp16[0] << ", " <<
445*5f32b710SXin Li 			"F32(F16) = 0x" << std::setw(8) << fp32.lo[0] << ", " <<
446*5f32b710SXin Li 			"F32 = 0x" << std::setw(8) << fp16_ieee_to_fp32_bits(fp16[0]);
447*5f32b710SXin Li 		EXPECT_EQ(fp16_ieee_to_fp32_bits(fp16[1]), fp32.lo[1]) <<
448*5f32b710SXin Li 			std::hex << std::uppercase << std::setfill('0') <<
449*5f32b710SXin Li 			"F16 = 0x" << std::setw(4) << fp16[1] << ", " <<
450*5f32b710SXin Li 			"F32(F16) = 0x" << std::setw(8) << fp32.lo[1] << ", " <<
451*5f32b710SXin Li 			"F32 = 0x" << std::setw(8) << fp16_ieee_to_fp32_bits(fp16[1]);
452*5f32b710SXin Li 		EXPECT_EQ(fp16_ieee_to_fp32_bits(fp16[2]), fp32.lo[2]) <<
453*5f32b710SXin Li 			std::hex << std::uppercase << std::setfill('0') <<
454*5f32b710SXin Li 			"F16 = 0x" << std::setw(4) << fp16[2] << ", " <<
455*5f32b710SXin Li 			"F32(F16) = 0x" << std::setw(8) << fp32.lo[2] << ", " <<
456*5f32b710SXin Li 			"F32 = 0x" << std::setw(8) << fp16_ieee_to_fp32_bits(fp16[2]);
457*5f32b710SXin Li 		EXPECT_EQ(fp16_ieee_to_fp32_bits(fp16[3]), fp32.lo[3]) <<
458*5f32b710SXin Li 			std::hex << std::uppercase << std::setfill('0') <<
459*5f32b710SXin Li 			"F16 = 0x" << std::setw(4) << fp16[3] << ", " <<
460*5f32b710SXin Li 			"F32(F16) = 0x" << std::setw(8) << fp32.lo[3] << ", " <<
461*5f32b710SXin Li 			"F32 = 0x" << std::setw(8) << fp16_ieee_to_fp32_bits(fp16[3]);
462*5f32b710SXin Li 		EXPECT_EQ(fp16_ieee_to_fp32_bits(fp16[4]), fp32.hi[0]) <<
463*5f32b710SXin Li 			std::hex << std::uppercase << std::setfill('0') <<
464*5f32b710SXin Li 			"F16 = 0x" << std::setw(4) << fp16[4] << ", " <<
465*5f32b710SXin Li 			"F32(F16) = 0x" << std::setw(8) << fp32.hi[0] << ", " <<
466*5f32b710SXin Li 			"F32 = 0x" << std::setw(8) << fp16_ieee_to_fp32_bits(fp16[4]);
467*5f32b710SXin Li 		EXPECT_EQ(fp16_ieee_to_fp32_bits(fp16[5]), fp32.hi[1]) <<
468*5f32b710SXin Li 			std::hex << std::uppercase << std::setfill('0') <<
469*5f32b710SXin Li 			"F16 = 0x" << std::setw(4) << fp16[5] << ", " <<
470*5f32b710SXin Li 			"F32(F16) = 0x" << std::setw(8) << fp32.hi[1] << ", " <<
471*5f32b710SXin Li 			"F32 = 0x" << std::setw(8) << fp16_ieee_to_fp32_bits(fp16[5]);
472*5f32b710SXin Li 		EXPECT_EQ(fp16_ieee_to_fp32_bits(fp16[6]), fp32.hi[2]) <<
473*5f32b710SXin Li 			std::hex << std::uppercase << std::setfill('0') <<
474*5f32b710SXin Li 			"F16 = 0x" << std::setw(4) << fp16[6] << ", " <<
475*5f32b710SXin Li 			"F32(F16) = 0x" << std::setw(8) << fp32.hi[2] << ", " <<
476*5f32b710SXin Li 			"F32 = 0x" << std::setw(8) << fp16_ieee_to_fp32_bits(fp16[6]);
477*5f32b710SXin Li 		EXPECT_EQ(fp16_ieee_to_fp32_bits(fp16[7]), fp32.hi[3]) <<
478*5f32b710SXin Li 			std::hex << std::uppercase << std::setfill('0') <<
479*5f32b710SXin Li 			"F16 = 0x" << std::setw(4) << fp16[7] << ", " <<
480*5f32b710SXin Li 			"F32(F16) = 0x" << std::setw(8) << fp32.hi[3] << ", " <<
481*5f32b710SXin Li 			"F32 = 0x" << std::setw(8) << fp16_ieee_to_fp32_bits(fp16[7]);
482*5f32b710SXin Li 	}
483*5f32b710SXin Li }
484*5f32b710SXin Li 
TEST(FP16_IEEE_TO_FP32x2_PSIMD,negative_denormalized_values)485*5f32b710SXin Li TEST(FP16_IEEE_TO_FP32x2_PSIMD, negative_denormalized_values) {
486*5f32b710SXin Li 	for (uint16_t h = 0; h < 0x0400; h += 8) {
487*5f32b710SXin Li 		const psimd_u16 fp16 = {
488*5f32b710SXin Li 			(uint16_t) (h + 0x8000),
489*5f32b710SXin Li 			(uint16_t) (h + 0x8001),
490*5f32b710SXin Li 			(uint16_t) (h + 0x8002),
491*5f32b710SXin Li 			(uint16_t) (h + 0x8003),
492*5f32b710SXin Li 			(uint16_t) (h + 0x8004),
493*5f32b710SXin Li 			(uint16_t) (h + 0x8005),
494*5f32b710SXin Li 			(uint16_t) (h + 0x8006),
495*5f32b710SXin Li 			(uint16_t) (h + 0x8007)
496*5f32b710SXin Li 		};
497*5f32b710SXin Li 		const psimd_u32x2 fp32 =
498*5f32b710SXin Li 			psimd_cast_f32x2_u32x2(fp16_ieee_to_fp32x2_psimd(fp16));
499*5f32b710SXin Li 
500*5f32b710SXin Li 		EXPECT_EQ(fp16_ieee_to_fp32_bits(fp16[0]), fp32.lo[0]) <<
501*5f32b710SXin Li 			std::hex << std::uppercase << std::setfill('0') <<
502*5f32b710SXin Li 			"F16 = 0x" << std::setw(4) << fp16[0] << ", " <<
503*5f32b710SXin Li 			"F32(F16) = 0x" << std::setw(8) << fp32.lo[0] << ", " <<
504*5f32b710SXin Li 			"F32 = 0x" << std::setw(8) << fp16_ieee_to_fp32_bits(fp16[0]);
505*5f32b710SXin Li 		EXPECT_EQ(fp16_ieee_to_fp32_bits(fp16[1]), fp32.lo[1]) <<
506*5f32b710SXin Li 			std::hex << std::uppercase << std::setfill('0') <<
507*5f32b710SXin Li 			"F16 = 0x" << std::setw(4) << fp16[1] << ", " <<
508*5f32b710SXin Li 			"F32(F16) = 0x" << std::setw(8) << fp32.lo[1] << ", " <<
509*5f32b710SXin Li 			"F32 = 0x" << std::setw(8) << fp16_ieee_to_fp32_bits(fp16[1]);
510*5f32b710SXin Li 		EXPECT_EQ(fp16_ieee_to_fp32_bits(fp16[2]), fp32.lo[2]) <<
511*5f32b710SXin Li 			std::hex << std::uppercase << std::setfill('0') <<
512*5f32b710SXin Li 			"F16 = 0x" << std::setw(4) << fp16[2] << ", " <<
513*5f32b710SXin Li 			"F32(F16) = 0x" << std::setw(8) << fp32.lo[2] << ", " <<
514*5f32b710SXin Li 			"F32 = 0x" << std::setw(8) << fp16_ieee_to_fp32_bits(fp16[2]);
515*5f32b710SXin Li 		EXPECT_EQ(fp16_ieee_to_fp32_bits(fp16[3]), fp32.lo[3]) <<
516*5f32b710SXin Li 			std::hex << std::uppercase << std::setfill('0') <<
517*5f32b710SXin Li 			"F16 = 0x" << std::setw(4) << fp16[3] << ", " <<
518*5f32b710SXin Li 			"F32(F16) = 0x" << std::setw(8) << fp32.lo[3] << ", " <<
519*5f32b710SXin Li 			"F32 = 0x" << std::setw(8) << fp16_ieee_to_fp32_bits(fp16[3]);
520*5f32b710SXin Li 		EXPECT_EQ(fp16_ieee_to_fp32_bits(fp16[4]), fp32.hi[0]) <<
521*5f32b710SXin Li 			std::hex << std::uppercase << std::setfill('0') <<
522*5f32b710SXin Li 			"F16 = 0x" << std::setw(4) << fp16[4] << ", " <<
523*5f32b710SXin Li 			"F32(F16) = 0x" << std::setw(8) << fp32.hi[0] << ", " <<
524*5f32b710SXin Li 			"F32 = 0x" << std::setw(8) << fp16_ieee_to_fp32_bits(fp16[4]);
525*5f32b710SXin Li 		EXPECT_EQ(fp16_ieee_to_fp32_bits(fp16[5]), fp32.hi[1]) <<
526*5f32b710SXin Li 			std::hex << std::uppercase << std::setfill('0') <<
527*5f32b710SXin Li 			"F16 = 0x" << std::setw(4) << fp16[5] << ", " <<
528*5f32b710SXin Li 			"F32(F16) = 0x" << std::setw(8) << fp32.hi[1] << ", " <<
529*5f32b710SXin Li 			"F32 = 0x" << std::setw(8) << fp16_ieee_to_fp32_bits(fp16[5]);
530*5f32b710SXin Li 		EXPECT_EQ(fp16_ieee_to_fp32_bits(fp16[6]), fp32.hi[2]) <<
531*5f32b710SXin Li 			std::hex << std::uppercase << std::setfill('0') <<
532*5f32b710SXin Li 			"F16 = 0x" << std::setw(4) << fp16[6] << ", " <<
533*5f32b710SXin Li 			"F32(F16) = 0x" << std::setw(8) << fp32.hi[2] << ", " <<
534*5f32b710SXin Li 			"F32 = 0x" << std::setw(8) << fp16_ieee_to_fp32_bits(fp16[6]);
535*5f32b710SXin Li 		EXPECT_EQ(fp16_ieee_to_fp32_bits(fp16[7]), fp32.hi[3]) <<
536*5f32b710SXin Li 			std::hex << std::uppercase << std::setfill('0') <<
537*5f32b710SXin Li 			"F16 = 0x" << std::setw(4) << fp16[7] << ", " <<
538*5f32b710SXin Li 			"F32(F16) = 0x" << std::setw(8) << fp32.hi[3] << ", " <<
539*5f32b710SXin Li 			"F32 = 0x" << std::setw(8) << fp16_ieee_to_fp32_bits(fp16[7]);
540*5f32b710SXin Li 	}
541*5f32b710SXin Li }
542