@@ -182,6 +182,7 @@ static int fp_check_data(struct hwtest_ctx *ctx, uint32_t op1, uint32_t op2, con
182
182
int sop ;
183
183
int rm ;
184
184
bool neg = false;
185
+ uint64_t t64 ;
185
186
switch (op ) {
186
187
case 0xa2 : /* i2f */
187
188
case 0xa3 : /* i2f */
@@ -239,6 +240,57 @@ static int fp_check_data(struct hwtest_ctx *ctx, uint32_t op1, uint32_t op2, con
239
240
ecc = fp32_cmp (exp , 0 );
240
241
}
241
242
break ;
243
+ case 0xa4 : /* f2i */
244
+ case 0xa5 : /* f2i */
245
+ if (!(op2 & 0x00004000 ))
246
+ s1 = fp16_to_fp32 (s1 );
247
+ if (op2 & 0x00100000 )
248
+ s1 &= ~0x80000000 ;
249
+ if (op2 & 0x20000000 )
250
+ s1 ^= 0x80000000 ;
251
+ rm = op2 >> 17 & 3 ;
252
+ if (s1 & 0x80000000 ) {
253
+ neg = true;
254
+ s1 ^= 0x80000000 ;
255
+ rm = fp_flip_rm (rm );
256
+ }
257
+ t64 = fp32_to_u64 (s1 , rm );
258
+ if (t64 >> 32 )
259
+ t64 = 0xffffffff ;
260
+ exp = t64 ;
261
+ if (op2 & 0x08000000 ) {
262
+ uint32_t limit = op2 & 0x04000000 ? 0x80000000 : 0x8000 ;
263
+ if (neg ) {
264
+ if (exp > limit )
265
+ exp = limit ;
266
+ exp = - exp ;
267
+ } else {
268
+ if (exp >= limit )
269
+ exp = limit - 1 ;
270
+ }
271
+ } else if (neg ) {
272
+ exp = 0 ;
273
+ } else if (!(op2 & 0x04000000 ) && exp >= 0x10000 ) {
274
+ exp = 0xffff ;
275
+ }
276
+ if (op2 & 0x04000000 ) {
277
+ if (exp & 0x80000000 )
278
+ ecc = 2 ;
279
+ else if (exp == 0 )
280
+ ecc = 1 ;
281
+ else
282
+ ecc = 0 ;
283
+ } else {
284
+ exp &= 0xffff ;
285
+ real &= 0xffff ;
286
+ if (exp & 0x8000 )
287
+ ecc = 2 ;
288
+ else if (exp == 0 )
289
+ ecc = 1 ;
290
+ else
291
+ ecc = 0 ;
292
+ }
293
+ break ;
242
294
case 0xa6 : /* f2f */
243
295
case 0xa7 : /* f2f */
244
296
if (!(op2 & 0x00004000 ))
@@ -740,6 +792,36 @@ static int test_i2f(struct hwtest_ctx *ctx) {
740
792
return HWTEST_RES_PASS ;
741
793
}
742
794
795
+ static int test_f2i (struct hwtest_ctx * ctx ) {
796
+ int i ;
797
+ for (i = 0 ; i < 100000 ; i ++ ) {
798
+ uint32_t op1 = 0xa0000001 | (jrand48 (ctx -> rand48 ) & 0x0fff0000 );
799
+ uint32_t op2 = 0x800007c0 | (jrand48 (ctx -> rand48 ) & 0x3fdff004 );
800
+ /* Select proper source/destination for fp32 vs fp16 */
801
+ if (op2 & 0x04000000 )
802
+ op1 |= 0x1c ;
803
+ else
804
+ op1 |= 0x38 ;
805
+ if (op2 & 0x00004000 )
806
+ op1 |= 0x800 ;
807
+ else
808
+ op1 |= 0x1000 ;
809
+ /* This bit selects fp64 on G200+ */
810
+ if (ctx -> chipset >= 0xa0 )
811
+ op2 &= ~0x00400000 ;
812
+ uint32_t xtra = jrand48 (ctx -> rand48 );
813
+ if (fp_prep_grid (ctx , xtra ))
814
+ return HWTEST_RES_FAIL ;
815
+ if (fp_prep_code (ctx , op1 , op2 ))
816
+ return HWTEST_RES_FAIL ;
817
+ uint32_t src1 [0x200 ], src2 [0x200 ], src3 [0x200 ];
818
+ fp_gen (ctx , src1 , src2 , src3 );
819
+ if (fp_test (ctx , op1 , op2 , src1 , src2 , src3 , xtra ))
820
+ return HWTEST_RES_FAIL ;
821
+ }
822
+ return HWTEST_RES_PASS ;
823
+ }
824
+
743
825
static int test_f2f (struct hwtest_ctx * ctx ) {
744
826
int i ;
745
827
for (i = 0 ; i < 100000 ; i ++ ) {
@@ -785,5 +867,6 @@ HWTEST_DEF_GROUP(g80_fp,
785
867
HWTEST_TEST (test_fmul_i , 0 ),
786
868
HWTEST_TEST (test_fmad_i , 0 ),
787
869
HWTEST_TEST (test_i2f , 0 ),
870
+ HWTEST_TEST (test_f2i , 0 ),
788
871
HWTEST_TEST (test_f2f , 0 ),
789
872
)
0 commit comments