Avoid inlining floor into rem_pio2

Possible workaround for
https://github.com/rust-lang/compiler-builtins/pull/976#issuecomment-3085530354

Inline assembly in the body of a function currently causes the compiler
to consider that function possibly unwinding, even if said asm
originated from inlining an `extern "C"` function. This patch wraps the
problematic callsite with `#[inline(never)]`.
This commit is contained in:
quaternic
2025-07-27 08:26:58 +03:00
committed by GitHub
parent 474315828b
commit c061e73d9f

View File

@@ -11,7 +11,7 @@
* ====================================================
*/
use super::{floor, scalbn};
use super::scalbn;
// initial value for jk
const INIT_JK: [usize; 4] = [3, 4, 4, 6];
@@ -223,6 +223,14 @@ const PIO2: [f64; 8] = [
/// independent of the exponent of the input.
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
pub(crate) fn rem_pio2_large(x: &[f64], y: &mut [f64], e0: i32, prec: usize) -> i32 {
// FIXME(rust-lang/rust#144518): Inline assembly would cause `no_panic` to fail
// on the callers of this function. As a workaround, avoid inlining `floor` here
// when implemented with assembly.
#[cfg_attr(x86_no_sse, inline(never))]
extern "C" fn floor(x: f64) -> f64 {
super::floor(x)
}
let x1p24 = f64::from_bits(0x4170000000000000); // 0x1p24 === 2 ^ 24
let x1p_24 = f64::from_bits(0x3e70000000000000); // 0x1p_24 === 2 ^ (-24)