Skip to content

Commit 041cfee

Browse files
committed
Attempt to avoid LLVM error
1 parent 2f062b8 commit 041cfee

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed

Cargo.lock

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/std_float/src/lib.rs

+14-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![cfg_attr(feature = "as_crate", no_std)] // We are std!
21
#![cfg_attr(
32
feature = "as_crate",
43
feature(core_intrinsics),
@@ -102,7 +101,20 @@ pub trait StdFloat: Sealed + Sized {
102101
#[inline]
103102
#[must_use = "method returns a new vector and does not mutate the original value"]
104103
fn ln(self) -> Self {
105-
unsafe { intrinsics::simd_flog(self) }
104+
// https://github.com/llvm/llvm-project/issues/83729
105+
#[cfg(target_arch = "aarch64")]
106+
{
107+
let mut ln = Self::splat(0f64);
108+
for i in 0..N {
109+
ln[i] = self[i].ln()
110+
}
111+
ln
112+
}
113+
114+
#[cfg(not(target_arch = "aarch64"))]
115+
{
116+
unsafe { intrinsics::simd_flog(self) }
117+
}
106118
}
107119

108120
/// Produces a vector where every element has the logarithm with respect to an arbitrary

crates/std_float/tests/float.rs

+11-1
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,19 @@ macro_rules! impl_tests {
5353
mod $scalar {
5454
use std_float::StdFloat;
5555

56-
unary_test! { $scalar, sqrt, sin, cos, exp, exp2, ln, log2, log10, ceil, floor, round, trunc, fract }
56+
unary_test! { $scalar, sqrt, sin, cos, exp, exp2, ln, log2, log10, ceil, floor, round, trunc }
5757
binary_test! { $scalar, log }
5858
ternary_test! { $scalar, mul_add }
59+
60+
test_helpers::test_lanes! {
61+
fn fract<const LANES: usize>() {
62+
test_helpers::test_unary_elementwise_flush_subnormals(
63+
&core_simd::simd::Simd::<$scalar, LANES>::fract,
64+
&$scalar::fract,
65+
&|_| true,
66+
)
67+
}
68+
}
5969
}
6070
}
6171
}

0 commit comments

Comments
 (0)