Skip to content

Commit

Permalink
Merge pull request #297 from GuillaumeGomez/only-soft-floats
Browse files Browse the repository at this point in the history
  • Loading branch information
Amanieu authored Aug 8, 2024
2 parents 279e5f6 + 5aeb0be commit 300edb3
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 5 deletions.
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ unstable = []
# musl libc.
musl-reference-tests = ['rand']

# Used to prevent using any intrinsics or arch-specific code.
force-soft-floats = []

[workspace]
members = [
"crates/compiler-builtins-smoke-test",
Expand Down
1 change: 1 addition & 0 deletions crates/compiler-builtins-smoke-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ bench = false
[features]
unstable = []
checked = []
force-soft-floats = []
2 changes: 1 addition & 1 deletion src/math/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ macro_rules! div {

macro_rules! llvm_intrinsically_optimized {
(#[cfg($($clause:tt)*)] $e:expr) => {
#[cfg(all(feature = "unstable", $($clause)*))]
#[cfg(all(feature = "unstable", not(feature = "force-soft-floats"), $($clause)*))]
{
if true { // thwart the dead code lint
$e
Expand Down
4 changes: 2 additions & 2 deletions src/math/sqrt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ pub fn sqrt(x: f64) -> f64 {
}
}
}
#[cfg(target_feature = "sse2")]
#[cfg(all(target_feature = "sse2", not(feature = "force-soft-floats")))]
{
// Note: This path is unlikely since LLVM will usually have already
// optimized sqrt calls into hardware instructions if sse2 is available,
Expand All @@ -107,7 +107,7 @@ pub fn sqrt(x: f64) -> f64 {
_mm_cvtsd_f64(m_sqrt)
}
}
#[cfg(not(target_feature = "sse2"))]
#[cfg(any(not(target_feature = "sse2"), feature = "force-soft-floats"))]
{
use core::num::Wrapping;

Expand Down
4 changes: 2 additions & 2 deletions src/math/sqrtf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub fn sqrtf(x: f32) -> f32 {
}
}
}
#[cfg(target_feature = "sse")]
#[cfg(all(target_feature = "sse", not(feature = "force-soft-floats")))]
{
// Note: This path is unlikely since LLVM will usually have already
// optimized sqrt calls into hardware instructions if sse is available,
Expand All @@ -42,7 +42,7 @@ pub fn sqrtf(x: f32) -> f32 {
_mm_cvtss_f32(m_sqrt)
}
}
#[cfg(not(target_feature = "sse"))]
#[cfg(any(not(target_feature = "sse"), feature = "force-soft-floats"))]
{
const TINY: f32 = 1.0e-30;

Expand Down

0 comments on commit 300edb3

Please sign in to comment.