@@ -227,9 +227,8 @@ where
227227 let one = IeeeFloat :: < S > :: one ( ) ;
228228 let two = IeeeFloat :: < S > :: two ( ) ;
229229 let pi = IeeeFloat :: < S > :: pi ( ) ;
230- let pi_over_2 = IeeeFloat :: < S > :: frac_pi_2 ( ) ;
230+ let pi_over_2 = ( pi / two ) . value ;
231231
232- // Exclusive ranges are made using next_up/next_down.
233232 match intrinsic_name {
234233 // sin, cos, tanh: [-1, 1]
235234 #[ rustfmt:: skip]
@@ -254,20 +253,17 @@ where
254253 "asinf" | "asin" => val. clamp ( pi. neg ( ) , pi) ,
255254
256255 // atan: (-π/2, +π/2)
257- "atanf" | "atan" => val. clamp ( pi_over_2. neg ( ) . next_up ( ) . value , pi_over_2. next_down ( ) . value ) ,
256+ "atanf" | "atan" => val. clamp ( pi_over_2. neg ( ) , pi_over_2) ,
258257
259258 // erfc: (-1, 1)
260- "erff" | "erf" => val. clamp ( one. neg ( ) . next_up ( ) . value , one. next_down ( ) . value ) ,
259+ "erff" | "erf" => val. clamp ( one. neg ( ) , one) ,
261260
262261 // erfc: (0, 2)
263- "erfcf" | "erfc" => val. clamp ( zero. next_up ( ) . value , two. next_down ( ) . value ) ,
262+ "erfcf" | "erfc" => val. clamp ( zero, two) ,
264263
265264 // atan2(y, x): arctan(y/x) in [−π, +π]
266265 "atan2f" | "atan2" => val. clamp ( pi. neg ( ) , pi) ,
267266
268- // FIXME: According to Wolfram Alpha, the range of ln(gamma) is [-0.121486, +INF]. What to do?
269- "lgammaf_r" | "lgamma_r" => val,
270-
271267 _ => val,
272268 }
273269}
@@ -1323,12 +1319,12 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
13231319 IeeeFloat < S > : IeeeExt ,
13241320 {
13251321 let this = self . eval_context_mut ( ) ;
1326- let zero = IeeeFloat :: < S > :: ZERO ;
13271322 let one = IeeeFloat :: < S > :: one ( ) ;
1323+ let two = IeeeFloat :: < S > :: two ( ) ;
13281324 let three = IeeeFloat :: < S > :: three ( ) ;
13291325 let pi = IeeeFloat :: < S > :: pi ( ) ;
1330- let pi_over_2 = IeeeFloat :: < S > :: frac_pi_2 ( ) ;
1331- let pi_over_4 = IeeeFloat :: < S > :: frac_pi_4 ( ) ;
1326+ let pi_over_2 = ( pi / two ) . value ;
1327+ let pi_over_4 = ( pi_over_2 / two ) . value ;
13321328
13331329 Some ( match ( intrinsic_name, args) {
13341330 // cos(±0) and cosh(±0)= 1
@@ -1349,11 +1345,6 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
13491345 // erfc(-INF) = 2
13501346 ( "erfcf" | "erfc" , [ input] ) if input. is_neg_infinity ( ) => ( one + one) . value ,
13511347
1352- // erfc(+INF) = 0
1353- // REVIEW/HELP: for some reason the tests fail because erfc(+INF) = 1e-45. Which is weird because
1354- // no error can be applied to 0. Checked and this does not happen without Miri.
1355- ( "erfcf" | "erfc" , [ input] ) if input. is_pos_infinity ( ) => zero,
1356-
13571348 // hypot(x, ±0) = abs(x), if x is not a NaN.
13581349 ( "_hypotf" | "hypotf" | "_hypot" | "hypot" , [ x, y] ) if !x. is_nan ( ) && y. is_zero ( ) =>
13591350 x. abs ( ) ,
0 commit comments