Skip to content

Commit cc048b6

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

File tree

3 files changed

+39
-6
lines changed

3 files changed

+39
-6
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

+26-5
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),
@@ -99,11 +98,8 @@ pub trait StdFloat: Sealed + Sized {
9998

10099
/// Produces a vector where every element has the natural logarithm of the value
101100
/// in the equivalently-indexed element in `self`.
102-
#[inline]
103101
#[must_use = "method returns a new vector and does not mutate the original value"]
104-
fn ln(self) -> Self {
105-
unsafe { intrinsics::simd_flog(self) }
106-
}
102+
fn ln(self) -> Self;
107103

108104
/// Produces a vector where every element has the logarithm with respect to an arbitrary
109105
/// in the equivalently-indexed elements in `self` and `base`.
@@ -176,6 +172,12 @@ where
176172
fn fract(self) -> Self {
177173
self - self.trunc()
178174
}
175+
176+
#[inline]
177+
#[must_use = "method returns a new vector and does not mutate the original value"]
178+
fn ln(self) -> Self {
179+
unsafe { intrinsics::simd_flog(self) }
180+
}
179181
}
180182

181183
impl<const N: usize> StdFloat for Simd<f64, N>
@@ -188,4 +190,23 @@ where
188190
fn fract(self) -> Self {
189191
self - self.trunc()
190192
}
193+
194+
#[inline]
195+
#[must_use = "method returns a new vector and does not mutate the original value"]
196+
fn ln(self) -> Self {
197+
// https://github.com/llvm/llvm-project/issues/83729
198+
#[cfg(target_arch = "aarch64")]
199+
{
200+
let mut ln = Self::splat(0f64);
201+
for i in 0..N {
202+
ln[i] = self[i].ln()
203+
}
204+
ln
205+
}
206+
207+
#[cfg(not(target_arch = "aarch64"))]
208+
{
209+
unsafe { intrinsics::simd_flog(self) }
210+
}
211+
}
191212
}

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)