From 68f1e5addb0596b8c43499196ddced977194606e Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 6 Jan 2025 10:13:07 -0800 Subject: [PATCH] More MinGW fixes --- crates/math/src/lib.rs | 10 ++++++---- crates/wasmtime/src/runtime/vm/libcalls.rs | 4 ++-- pulley/src/interp.rs | 4 ++-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/crates/math/src/lib.rs b/crates/math/src/lib.rs index ae305cd9df61..008cedfa7d79 100644 --- a/crates/math/src/lib.rs +++ b/crates/math/src/lib.rs @@ -31,7 +31,7 @@ pub trait WasmFloat { fn wasm_nearest(self) -> Self; fn wasm_minimum(self, other: Self) -> Self; fn wasm_maximum(self, other: Self) -> Self; - fn mul_add(self, b: Self, c: Self) -> Self; + fn wasm_mul_add(self, b: Self, c: Self) -> Self; } impl WasmFloat for f32 { @@ -148,9 +148,11 @@ impl WasmFloat for f32 { } } #[inline] - fn mul_add(self, b: f32, c: f32) -> f32 { + fn wasm_mul_add(self, b: f32, c: f32) -> f32 { + // The MinGW implementation of `fma` differs from other platforms, so + // favor `libm` there instead. #[cfg(feature = "std")] - if true { + if !(cfg!(windows) && cfg!(target_env = "gnu")) { return self.mul_add(b, c); } libm::fmaf(self, b, c) @@ -271,7 +273,7 @@ impl WasmFloat for f64 { } } #[inline] - fn mul_add(self, b: f64, c: f64) -> f64 { + fn wasm_mul_add(self, b: f64, c: f64) -> f64 { // The MinGW implementation of `fma` differs from other platforms, so // favor `libm` there instead. #[cfg(feature = "std")] diff --git a/crates/wasmtime/src/runtime/vm/libcalls.rs b/crates/wasmtime/src/runtime/vm/libcalls.rs index cb4d6c04d842..ef9572ea7d8b 100644 --- a/crates/wasmtime/src/runtime/vm/libcalls.rs +++ b/crates/wasmtime/src/runtime/vm/libcalls.rs @@ -1289,11 +1289,11 @@ pub mod relocs { } pub extern "C" fn fmaf32(a: f32, b: f32, c: f32) -> f32 { - wasmtime_math::WasmFloat::mul_add(a, b, c) + wasmtime_math::WasmFloat::wasm_mul_add(a, b, c) } pub extern "C" fn fmaf64(a: f64, b: f64, c: f64) -> f64 { - wasmtime_math::WasmFloat::mul_add(a, b, c) + wasmtime_math::WasmFloat::wasm_mul_add(a, b, c) } // This intrinsic is only used on x86_64 platforms as an implementation of diff --git a/pulley/src/interp.rs b/pulley/src/interp.rs index a6e6de98c643..9202acb6a8c4 100644 --- a/pulley/src/interp.rs +++ b/pulley/src/interp.rs @@ -4775,7 +4775,7 @@ impl ExtendedOpVisitor for Interpreter<'_> { let b = self.state[b].get_f32x4(); let c = self.state[c].get_f32x4(); for ((a, b), c) in a.iter_mut().zip(b).zip(c) { - *a = a.mul_add(b, c); + *a = a.wasm_mul_add(b, c); } self.state[dst].set_f32x4(a); ControlFlow::Continue(()) @@ -4786,7 +4786,7 @@ impl ExtendedOpVisitor for Interpreter<'_> { let b = self.state[b].get_f64x2(); let c = self.state[c].get_f64x2(); for ((a, b), c) in a.iter_mut().zip(b).zip(c) { - *a = a.mul_add(b, c); + *a = a.wasm_mul_add(b, c); } self.state[dst].set_f64x2(a); ControlFlow::Continue(())