Skip to content

Add a no-f64 version of fmaf #875

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ci/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@ fi

mflags=()

nowiden_tests=$(grep -vE '^#' etc/has-nowiden-impl.txt | tr '\n' ' ')

# We enumerate features manually.
mflags+=(--no-default-features)

Expand Down Expand Up @@ -283,6 +285,7 @@ else
# Test the same in release mode, which also increases coverage. Also ensure
# the soft float routines are checked.
"${cmd[@]}" "$profile_flag" release-checked
[ -n "${nowiden_tests:-}" ] && LIBM_F32_NO_WIDEN=1 "${cmd[@]}" "$profile_flag" release-checked -- $nowiden_tests
"${cmd[@]}" "$profile_flag" release-checked --features force-soft-floats
"${cmd[@]}" "$profile_flag" release-checked --features unstable-intrinsics
"${cmd[@]}" "$profile_flag" release-checked --features unstable-intrinsics --benches
Expand Down
2 changes: 2 additions & 0 deletions etc/has-nowiden-impl.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Functions that have a different version based on f32_no_widen
fmaf
10 changes: 10 additions & 0 deletions libm/configure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ pub fn emit_libm_config(cfg: &Config) {
emit_intrinsics_cfg();
emit_arch_cfg();
emit_optimization_cfg(cfg);
emit_widen_cfg(cfg);
emit_cfg_shorthands(cfg);
emit_cfg_env(cfg);
emit_f16_f128_cfg(cfg);
Expand Down Expand Up @@ -96,6 +97,15 @@ fn emit_optimization_cfg(cfg: &Config) {
}
}

fn emit_widen_cfg(_cfg: &Config) {
println!("cargo:rustc-check-cfg=cfg(f32_no_widen)");
println!("cargo:rerun-if-env-changed=LIBM_F32_NO_WIDEN");

if env::var_os("LIBM_F32_NO_WIDEN").is_some() {
println!("cargo:rustc-cfg=f32_no_widen");
}
}

/// Provide an alias for common longer config combinations.
fn emit_cfg_shorthands(cfg: &Config) {
println!("cargo:rustc-check-cfg=cfg(x86_no_sse)");
Expand Down
6 changes: 5 additions & 1 deletion libm/src/math/fma_wide.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ pub fn fmaf(x: f32, y: f32, z: f32) -> f32 {
args: x, y, z,
}

fma_wide_round(x, y, z, Round::Nearest).val
if cfg!(f32_no_widen) {
super::fma::fma_round(x, y, z, Round::Nearest).val
} else {
fma_wide_round(x, y, z, Round::Nearest).val
}
}

/// Fma implementation when a hardware-backed larger float type is available. For `f32` and `f64`,
Expand Down
Loading