]> git.nega.tv - josh/narcissus/commitdiff
Add fallback for `round_ties_to_even` SSE4.1 path
authorJoshua Simmons <josh@nega.tv>
Fri, 11 Nov 2022 21:53:38 +0000 (22:53 +0100)
committerJoshua Simmons <josh@nega.tv>
Fri, 11 Nov 2022 21:53:38 +0000 (22:53 +0100)
narcissus-maths/src/lib.rs

index 2e71ed061a729941a85c193f4a0f842b08aff173..e653a05fbe84e41485b075edf0f0a8d288bb7345 100644 (file)
@@ -187,6 +187,10 @@ fn round_ties_to_even(x: f32) -> f32 {
         let x = _mm_round_ss::<ROUNDING>(x, x);
         std::arch::x86_64::_mm_cvtss_f32(x)
     }
+
+    // Incorrect if the rounding mode is changed.
+    #[cfg(not(target_feature = "sse4.1"))]
+    x.round()
 }
 
 #[macro_export]