|
| 1 | +From 2aa88b261ffb51d3f18a4b9d3b79232d7445e5f3 Mon Sep 17 00:00:00 2001 |
| 2 | +From: bjorn3 <17426603+bjorn3@users.noreply.github.com> |
| 3 | +Date: Thu, 16 Apr 2026 17:29:02 +0200 |
| 4 | +Subject: [PATCH] Disable f16 usage in portable-simd |
| 5 | + |
| 6 | +It is currently broken on x86_64-pc-windows-gnu |
| 7 | +--- |
| 8 | + Cargo.toml | 8 ++------ |
| 9 | + crates/core_simd/src/alias.rs | 10 ---------- |
| 10 | + crates/core_simd/src/cast.rs | 3 --- |
| 11 | + crates/core_simd/src/lib.rs | 1 - |
| 12 | + crates/core_simd/src/ops.rs | 2 +- |
| 13 | + crates/core_simd/src/ops/unary.rs | 2 -- |
| 14 | + crates/core_simd/src/simd/cmp/eq.rs | 2 +- |
| 15 | + crates/core_simd/src/simd/cmp/ord.rs | 2 +- |
| 16 | + crates/core_simd/src/simd/num/float.rs | 2 +- |
| 17 | + crates/core_simd/src/vector.rs | 7 ------- |
| 18 | + crates/core_simd/tests/f16_ops.rs | 10 ---------- |
| 19 | + crates/std_float/src/lib.rs | 9 --------- |
| 20 | + crates/test_helpers/src/biteq.rs | 2 +- |
| 21 | + crates/test_helpers/src/lib.rs | 2 -- |
| 22 | + crates/test_helpers/src/subnormals.rs | 2 +- |
| 23 | + 15 files changed, 8 insertions(+), 56 deletions(-) |
| 24 | + delete mode 100644 crates/core_simd/tests/f16_ops.rs |
| 25 | + |
| 26 | +diff --git a/Cargo.toml b/Cargo.toml |
| 27 | +index 883140b..45296b4 100644 |
| 28 | +--- a/Cargo.toml |
| 29 | ++++ b/Cargo.toml |
| 30 | +@@ -1,10 +1,6 @@ |
| 31 | + [workspace] |
| 32 | + resolver = "1" |
| 33 | +-members = [ |
| 34 | +- "crates/core_simd", |
| 35 | +- "crates/std_float", |
| 36 | +- "crates/test_helpers", |
| 37 | +-] |
| 38 | ++members = ["crates/core_simd", "crates/std_float", "crates/test_helpers"] |
| 39 | + |
| 40 | + [profile.test.package."*"] |
| 41 | + opt-level = 2 |
| 42 | +@@ -15,4 +11,4 @@ opt-level = 2 |
| 43 | + [workspace.dependencies.proptest] |
| 44 | + version = "1.11" |
| 45 | + default-features = false |
| 46 | +-features = ["alloc", "f16"] |
| 47 | ++features = ["alloc"] |
| 48 | +diff --git a/crates/core_simd/src/alias.rs b/crates/core_simd/src/alias.rs |
| 49 | +index 6dcfcb6..23f121c 100644 |
| 50 | +--- a/crates/core_simd/src/alias.rs |
| 51 | ++++ b/crates/core_simd/src/alias.rs |
| 52 | +@@ -153,16 +153,6 @@ alias! { |
| 53 | + usizex64 64 |
| 54 | + } |
| 55 | + |
| 56 | +- f16 = { |
| 57 | +- f16x1 1 |
| 58 | +- f16x2 2 |
| 59 | +- f16x4 4 |
| 60 | +- f16x8 8 |
| 61 | +- f16x16 16 |
| 62 | +- f16x32 32 |
| 63 | +- f16x64 64 |
| 64 | +- } |
| 65 | +- |
| 66 | + f32 = { |
| 67 | + f32x1 1 |
| 68 | + f32x2 2 |
| 69 | +diff --git a/crates/core_simd/src/cast.rs b/crates/core_simd/src/cast.rs |
| 70 | +index 69dc7ba..1c3592f 100644 |
| 71 | +--- a/crates/core_simd/src/cast.rs |
| 72 | ++++ b/crates/core_simd/src/cast.rs |
| 73 | +@@ -44,9 +44,6 @@ impl SimdCast for u64 {} |
| 74 | + unsafe impl Sealed for usize {} |
| 75 | + impl SimdCast for usize {} |
| 76 | + // Safety: primitive number types can be cast to other primitive number types |
| 77 | +-unsafe impl Sealed for f16 {} |
| 78 | +-impl SimdCast for f16 {} |
| 79 | +-// Safety: primitive number types can be cast to other primitive number types |
| 80 | + unsafe impl Sealed for f32 {} |
| 81 | + impl SimdCast for f32 {} |
| 82 | + // Safety: primitive number types can be cast to other primitive number types |
| 83 | +diff --git a/crates/core_simd/src/lib.rs b/crates/core_simd/src/lib.rs |
| 84 | +index 413a886..115be44 100644 |
| 85 | +--- a/crates/core_simd/src/lib.rs |
| 86 | ++++ b/crates/core_simd/src/lib.rs |
| 87 | +@@ -1,7 +1,6 @@ |
| 88 | + #![no_std] |
| 89 | + #![feature( |
| 90 | + convert_float_to_int, |
| 91 | +- f16, |
| 92 | + core_intrinsics, |
| 93 | + decl_macro, |
| 94 | + repr_simd, |
| 95 | +diff --git a/crates/core_simd/src/ops.rs b/crates/core_simd/src/ops.rs |
| 96 | +index c0a06ed..eb6601f 100644 |
| 97 | +--- a/crates/core_simd/src/ops.rs |
| 98 | ++++ b/crates/core_simd/src/ops.rs |
| 99 | +@@ -245,7 +245,7 @@ for_base_ops! { |
| 100 | + // We don't need any special precautions here: |
| 101 | + // Floats always accept arithmetic ops, but may become NaN. |
| 102 | + for_base_ops! { |
| 103 | +- T = (f16, f32, f64); |
| 104 | ++ T = (f32, f64); |
| 105 | + type Lhs = Simd<T, N>; |
| 106 | + type Rhs = Simd<T, N>; |
| 107 | + type Output = Self; |
| 108 | +diff --git a/crates/core_simd/src/ops/unary.rs b/crates/core_simd/src/ops/unary.rs |
| 109 | +index af7aa8a..e1c0616 100644 |
| 110 | +--- a/crates/core_simd/src/ops/unary.rs |
| 111 | ++++ b/crates/core_simd/src/ops/unary.rs |
| 112 | +@@ -19,8 +19,6 @@ macro_rules! neg { |
| 113 | + } |
| 114 | + |
| 115 | + neg! { |
| 116 | +- impl<const N: usize> Neg for Simd<f16, N> |
| 117 | +- |
| 118 | + impl<const N: usize> Neg for Simd<f32, N> |
| 119 | + |
| 120 | + impl<const N: usize> Neg for Simd<f64, N> |
| 121 | +diff --git a/crates/core_simd/src/simd/cmp/eq.rs b/crates/core_simd/src/simd/cmp/eq.rs |
| 122 | +index 7683640..d553d6c 100644 |
| 123 | +--- a/crates/core_simd/src/simd/cmp/eq.rs |
| 124 | ++++ b/crates/core_simd/src/simd/cmp/eq.rs |
| 125 | +@@ -42,7 +42,7 @@ macro_rules! impl_number { |
| 126 | + } |
| 127 | + } |
| 128 | + |
| 129 | +-impl_number! { f16, f32, f64, u8, u16, u32, u64, usize, i8, i16, i32, i64, isize } |
| 130 | ++impl_number! { f32, f64, u8, u16, u32, u64, usize, i8, i16, i32, i64, isize } |
| 131 | + |
| 132 | + macro_rules! impl_mask { |
| 133 | + { $($integer:ty),* } => { |
| 134 | +diff --git a/crates/core_simd/src/simd/cmp/ord.rs b/crates/core_simd/src/simd/cmp/ord.rs |
| 135 | +index 5a4e74c..5672fbb 100644 |
| 136 | +--- a/crates/core_simd/src/simd/cmp/ord.rs |
| 137 | ++++ b/crates/core_simd/src/simd/cmp/ord.rs |
| 138 | +@@ -144,7 +144,7 @@ macro_rules! impl_float { |
| 139 | + } |
| 140 | + } |
| 141 | + |
| 142 | +-impl_float! { f16, f32, f64 } |
| 143 | ++impl_float! { f32, f64 } |
| 144 | + |
| 145 | + macro_rules! impl_mask { |
| 146 | + { $($integer:ty),* } => { |
| 147 | +diff --git a/crates/core_simd/src/simd/num/float.rs b/crates/core_simd/src/simd/num/float.rs |
| 148 | +index 510f4c9..175cbce 100644 |
| 149 | +--- a/crates/core_simd/src/simd/num/float.rs |
| 150 | ++++ b/crates/core_simd/src/simd/num/float.rs |
| 151 | +@@ -444,4 +444,4 @@ macro_rules! impl_trait { |
| 152 | + } |
| 153 | + } |
| 154 | + |
| 155 | +-impl_trait! { f16 { bits: u16, mask: i16 }, f32 { bits: u32, mask: i32 }, f64 { bits: u64, mask: i64 } } |
| 156 | ++impl_trait! { f32 { bits: u32, mask: i32 }, f64 { bits: u64, mask: i64 } } |
| 157 | +diff --git a/crates/core_simd/src/vector.rs b/crates/core_simd/src/vector.rs |
| 158 | +index fbef69f..c8e0b8c 100644 |
| 159 | +--- a/crates/core_simd/src/vector.rs |
| 160 | ++++ b/crates/core_simd/src/vector.rs |
| 161 | +@@ -1146,13 +1146,6 @@ unsafe impl SimdElement for isize { |
| 162 | + type Mask = isize; |
| 163 | + } |
| 164 | + |
| 165 | +-impl Sealed for f16 {} |
| 166 | +- |
| 167 | +-// Safety: f16 is a valid SIMD element type, and is supported by this API |
| 168 | +-unsafe impl SimdElement for f16 { |
| 169 | +- type Mask = i16; |
| 170 | +-} |
| 171 | +- |
| 172 | + impl Sealed for f32 {} |
| 173 | + |
| 174 | + // Safety: f32 is a valid SIMD element type, and is supported by this API |
| 175 | +diff --git a/crates/core_simd/tests/f16_ops.rs b/crates/core_simd/tests/f16_ops.rs |
| 176 | +deleted file mode 100644 |
| 177 | +index f89bdf4..0000000 |
| 178 | +--- a/crates/core_simd/tests/f16_ops.rs |
| 179 | ++++ /dev/null |
| 180 | +@@ -1,10 +0,0 @@ |
| 181 | +-#![feature(portable_simd)] |
| 182 | +-#![feature(f16)] |
| 183 | +- |
| 184 | +-#[macro_use] |
| 185 | +-mod ops_macros; |
| 186 | +- |
| 187 | +-// FIXME: some f16 operations cause rustc to hang on wasm simd |
| 188 | +-// https://github.com/llvm/llvm-project/issues/189251 |
| 189 | +-#[cfg(not(all(target_arch = "wasm32", target_feature = "simd128")))] |
| 190 | +-impl_float_tests! { f16, i16 } |
| 191 | +diff --git a/crates/std_float/src/lib.rs b/crates/std_float/src/lib.rs |
| 192 | +index ff35254..acc1bfc 100644 |
| 193 | +--- a/crates/std_float/src/lib.rs |
| 194 | ++++ b/crates/std_float/src/lib.rs |
| 195 | +@@ -2,7 +2,6 @@ |
| 196 | + feature = "as_crate", |
| 197 | + feature(core_intrinsics), |
| 198 | + feature(portable_simd), |
| 199 | +- feature(f16), |
| 200 | + allow(internal_features) |
| 201 | + )] |
| 202 | + #[cfg(not(feature = "as_crate"))] |
| 203 | +@@ -170,17 +169,9 @@ pub trait StdFloat: Sealed + Sized { |
| 204 | + fn fract(self) -> Self; |
| 205 | + } |
| 206 | + |
| 207 | +-impl<const N: usize> Sealed for Simd<f16, N> {} |
| 208 | + impl<const N: usize> Sealed for Simd<f32, N> {} |
| 209 | + impl<const N: usize> Sealed for Simd<f64, N> {} |
| 210 | + |
| 211 | +-impl<const N: usize> StdFloat for Simd<f16, N> { |
| 212 | +- #[inline] |
| 213 | +- fn fract(self) -> Self { |
| 214 | +- self - self.trunc() |
| 215 | +- } |
| 216 | +-} |
| 217 | +- |
| 218 | + impl<const N: usize> StdFloat for Simd<f32, N> { |
| 219 | + #[inline] |
| 220 | + fn fract(self) -> Self { |
| 221 | +diff --git a/crates/test_helpers/src/biteq.rs b/crates/test_helpers/src/biteq.rs |
| 222 | +index 36761e3..cbc20cd 100644 |
| 223 | +--- a/crates/test_helpers/src/biteq.rs |
| 224 | ++++ b/crates/test_helpers/src/biteq.rs |
| 225 | +@@ -53,7 +53,7 @@ macro_rules! impl_float_biteq { |
| 226 | + }; |
| 227 | + } |
| 228 | + |
| 229 | +-impl_float_biteq! { f16, f32, f64 } |
| 230 | ++impl_float_biteq! { f32, f64 } |
| 231 | + |
| 232 | + impl<T> BitEq for *const T { |
| 233 | + fn biteq(&self, other: &Self) -> bool { |
| 234 | +diff --git a/crates/test_helpers/src/lib.rs b/crates/test_helpers/src/lib.rs |
| 235 | +index 82adb06..4b03674 100644 |
| 236 | +--- a/crates/test_helpers/src/lib.rs |
| 237 | ++++ b/crates/test_helpers/src/lib.rs |
| 238 | +@@ -1,4 +1,3 @@ |
| 239 | +-#![feature(f16)] |
| 240 | + #![cfg_attr( |
| 241 | + any(target_arch = "powerpc", target_arch = "powerpc64"), |
| 242 | + feature(powerpc_target_feature, stdarch_powerpc) |
| 243 | +@@ -47,7 +46,6 @@ impl_num! { u16 } |
| 244 | + impl_num! { u32 } |
| 245 | + impl_num! { u64 } |
| 246 | + impl_num! { usize } |
| 247 | +-impl_num! { f16 } |
| 248 | + impl_num! { f32 } |
| 249 | + impl_num! { f64 } |
| 250 | + |
| 251 | +diff --git a/crates/test_helpers/src/subnormals.rs b/crates/test_helpers/src/subnormals.rs |
| 252 | +index 44dfbb3..b5f19ba 100644 |
| 253 | +--- a/crates/test_helpers/src/subnormals.rs |
| 254 | ++++ b/crates/test_helpers/src/subnormals.rs |
| 255 | +@@ -39,7 +39,7 @@ macro_rules! impl_else { |
| 256 | + } |
| 257 | + } |
| 258 | + |
| 259 | +-impl_float! { f16, f32, f64 } |
| 260 | ++impl_float! { f32, f64 } |
| 261 | + impl_else! { i8, i16, i32, i64, isize, u8, u16, u32, u64, usize } |
| 262 | + |
| 263 | + /// AltiVec should flush subnormal inputs to zero, but QEMU seems to only flush outputs. |
| 264 | +-- |
| 265 | +2.53.0 |
| 266 | + |
0 commit comments