fpu bugs
This commit is contained in:
parent
27d9958a0a
commit
a3dcf24b1c
18
c/fpu.h
18
c/fpu.h
@ -165,10 +165,10 @@ static inline bool dn_f32_f32_f32(float32_t * a, float32_t * b, float32_t * c, u
|
|||||||
if ((!is_nan_f32(*a)) && (!is_nan_f32(*b)) && (!is_nan_f32(*c))) { // neither input is a NaN
|
if ((!is_nan_f32(*a)) && (!is_nan_f32(*b)) && (!is_nan_f32(*c))) { // neither input is a NaN
|
||||||
if (is_denormal_f32(*a) || is_denormal_f32(*b) || is_denormal_f32(*c)) { // either input is denormalized
|
if (is_denormal_f32(*a) || is_denormal_f32(*b) || is_denormal_f32(*c)) { // either input is denormalized
|
||||||
fpscr->cause_fpu_error = 1;
|
fpscr->cause_fpu_error = 1;
|
||||||
return false; // do not continue
|
return true; // do not continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return false;
|
||||||
case 1:
|
case 1:
|
||||||
/*
|
/*
|
||||||
* When FPSCR.DN is 1, a positive denormalized number is treated as
|
* When FPSCR.DN is 1, a positive denormalized number is treated as
|
||||||
@ -179,7 +179,7 @@ static inline bool dn_f32_f32_f32(float32_t * a, float32_t * b, float32_t * c, u
|
|||||||
if (is_denormal_f32(*a)) *a = flush_to_zero_f32(*a);
|
if (is_denormal_f32(*a)) *a = flush_to_zero_f32(*a);
|
||||||
if (is_denormal_f32(*b)) *b = flush_to_zero_f32(*b);
|
if (is_denormal_f32(*b)) *b = flush_to_zero_f32(*b);
|
||||||
if (is_denormal_f32(*c)) *c = flush_to_zero_f32(*c);
|
if (is_denormal_f32(*c)) *c = flush_to_zero_f32(*c);
|
||||||
return true;
|
return false;
|
||||||
default:
|
default:
|
||||||
assert(false);
|
assert(false);
|
||||||
}
|
}
|
||||||
@ -197,10 +197,10 @@ static inline bool dn_f32_f32(float32_t * a, float32_t * b, uint32_t * fps)
|
|||||||
if ((!is_nan_f32(*a)) && (!is_nan_f32(*b))) { // neither input is a NaN
|
if ((!is_nan_f32(*a)) && (!is_nan_f32(*b))) { // neither input is a NaN
|
||||||
if (is_denormal_f32(*a) || is_denormal_f32(*b)) { // either input is denormalized
|
if (is_denormal_f32(*a) || is_denormal_f32(*b)) { // either input is denormalized
|
||||||
fpscr->cause_fpu_error = 1;
|
fpscr->cause_fpu_error = 1;
|
||||||
return false; // do not continue
|
return true; // do not continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return false;
|
||||||
case 1:
|
case 1:
|
||||||
/*
|
/*
|
||||||
* When FPSCR.DN is 1, a positive denormalized number is treated as
|
* When FPSCR.DN is 1, a positive denormalized number is treated as
|
||||||
@ -210,7 +210,7 @@ static inline bool dn_f32_f32(float32_t * a, float32_t * b, uint32_t * fps)
|
|||||||
*/
|
*/
|
||||||
if (is_denormal_f32(*a)) *a = flush_to_zero_f32(*a);
|
if (is_denormal_f32(*a)) *a = flush_to_zero_f32(*a);
|
||||||
if (is_denormal_f32(*b)) *b = flush_to_zero_f32(*b);
|
if (is_denormal_f32(*b)) *b = flush_to_zero_f32(*b);
|
||||||
return true;
|
return false;
|
||||||
default:
|
default:
|
||||||
assert(false);
|
assert(false);
|
||||||
}
|
}
|
||||||
@ -440,7 +440,7 @@ static inline float64_t fabs_d(float64_t op1)
|
|||||||
|
|
||||||
static inline float32_t fneg_s(float32_t op1)
|
static inline float32_t fneg_s(float32_t op1)
|
||||||
{
|
{
|
||||||
op1.v ^= 0x80000000'00000000;
|
op1.v ^= 0x80000000;
|
||||||
return op1;
|
return op1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -496,7 +496,7 @@ static inline bool fcmpgt_s(float32_t op2, float32_t op1, uint32_t * fps)
|
|||||||
if (dn_f32_f32(&op2, &op1, fps)) return false;
|
if (dn_f32_f32(&op2, &op1, fps)) return false;
|
||||||
|
|
||||||
set_rounding_mode(fps);
|
set_rounding_mode(fps);
|
||||||
bool result = f32_le(op1, op2);
|
bool result = f32_le(op2, op1);
|
||||||
update_fpscr(fps);
|
update_fpscr(fps);
|
||||||
return !result;
|
return !result;
|
||||||
}
|
}
|
||||||
@ -506,7 +506,7 @@ static inline bool fcmpgt_d(float64_t op2, float64_t op1, uint32_t * fps)
|
|||||||
if (dn_f64_f64(&op2, &op1, fps)) return false;
|
if (dn_f64_f64(&op2, &op1, fps)) return false;
|
||||||
|
|
||||||
set_rounding_mode(fps);
|
set_rounding_mode(fps);
|
||||||
bool result = f64_le(op1, op2);
|
bool result = f64_le(op2, op1);
|
||||||
update_fpscr(fps);
|
update_fpscr(fps);
|
||||||
return !result;
|
return !result;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user