@@ -109,6 +109,7 @@ enum {
109
109
FMASK_SIGN = 0b10000000000000000000000000000000 ,
110
110
FMASK_EXPN = 0b01111111100000000000000000000000 ,
111
111
FMASK_FRAC = 0b00000000011111111111111111111111 ,
112
+ FMASK_QNAN = 0b00000000010000000000000000000000 ,
112
113
// ....xxxx....xxxx....xxxx....xxxx
113
114
FFLAG_MASK = 0b00000000000000000000000000011111 ,
114
115
FFLAG_INVALID_OP = 0b00000000000000000000000000010000 ,
@@ -312,7 +313,7 @@ static inline uint32_t calc_fclass(uint32_t f) {
312
313
/* 0x001 rs1 is -INF */
313
314
out |= (f == 0xff800000 ) ? 0x001 : 0 ;
314
315
/* 0x002 rs1 is negative normal */
315
- out |= (expn && expn < 0x78000000 && sign ) ? 0x002 : 0 ;
316
+ out |= (expn && ( expn != FMASK_EXPN ) && sign ) ? 0x002 : 0 ;
316
317
/* 0x004 rs1 is negative subnormal */
317
318
out |= (!expn && frac && sign ) ? 0x004 : 0 ;
318
319
/* 0x008 rs1 is -0 */
@@ -322,13 +323,13 @@ static inline uint32_t calc_fclass(uint32_t f) {
322
323
/* 0x020 rs1 is positive subnormal */
323
324
out |= (!expn && frac && !sign ) ? 0x020 : 0 ;
324
325
/* 0x040 rs1 is positive normal */
325
- out |= (expn && expn < 0x78000000 && !sign ) ? 0x040 : 0 ;
326
+ out |= (expn && ( expn != FMASK_EXPN ) && !sign ) ? 0x040 : 0 ;
326
327
/* 0x080 rs1 is +INF */
327
- out |= (f == 0x7f800000 ) ? 0x080 : 0 ;
328
+ out |= (expn == FMASK_EXPN && ! frac && ! sign ) ? 0x080 : 0 ;
328
329
/* 0x100 rs1 is a signaling NaN */
329
- out |= (expn == FMASK_EXPN && ( frac <= 0x7ff ) && frac ) ? 0x100 : 0 ;
330
+ out |= (expn == FMASK_EXPN && frac && !( frac & FMASK_QNAN ) ) ? 0x100 : 0 ;
330
331
/* 0x200 rs1 is a quiet NaN */
331
- out |= (expn == FMASK_EXPN && (frac >= 0x800 )) ? 0x200 : 0 ;
332
+ out |= (expn == FMASK_EXPN && (frac & FMASK_QNAN )) ? 0x200 : 0 ;
332
333
333
334
return out ;
334
335
}
0 commit comments