config: Replace cfg(x86_no_sse) with cfg(x86_no_sse2)

We use this option for both `f32`- and `f64`-related configuration, but
the original SSE only had support for single-precision operations.
Update this config to check for the SSE2 feature instead, which includes
double-precision support.

In practice this config is mostly used to differentiate between the i586
target (no SSE required) and the i686 target (SSE2 required) so for that
purpose, the existing behavior is fine. Building on an i586 baseline
with SSE enabled (but not sse2) also isn't really something we worry
about, so this change is mostly only for improving code readability.
This commit is contained in:
Trevor Gross
2026-03-29 20:59:12 -05:00
parent 419cad6d7e
commit 1560c85df4
24 changed files with 36 additions and 36 deletions
@@ -43,7 +43,7 @@ pub fn skip_sys_checks(test_name: &str) -> bool {
return true;
}
if cfg!(x86_no_sse) && X86_NO_SSE_SKIPPED.contains(&test_name) {
if cfg!(x86_no_sse2) && X86_NO_SSE_SKIPPED.contains(&test_name) {
return true;
}
@@ -113,7 +113,7 @@ fn $fn_add() {
}
}
#[cfg(not(x86_no_sse))]
#[cfg(not(x86_no_sse2))]
mod float_addsub {
use super::*;
@@ -128,7 +128,7 @@ mod float_addsub {
}
#[cfg(f128_enabled)]
#[cfg(not(x86_no_sse))]
#[cfg(not(x86_no_sse2))]
#[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))]
float_sum! {
f128, __addtf3, __subtf3, Quad, not(feature = "no-sys-f128");
@@ -139,7 +139,7 @@ fn $fn() {
};
}
#[cfg(not(x86_no_sse))]
#[cfg(not(x86_no_sse2))]
mod float_div {
use super::*;
@@ -1,7 +1,7 @@
#![allow(unused_macros, unused_features)]
#![cfg_attr(f128_enabled, feature(f128))]
#[cfg_attr(x86_no_sse, allow(unused))]
#[cfg_attr(x86_no_sse2, allow(unused))]
use builtins_test::*;
// This is approximate because of issues related to
@@ -53,7 +53,7 @@ fn $fn() {
};
}
#[cfg(not(x86_no_sse))] // FIXME(i586): failure for powidf2
#[cfg(not(x86_no_sse2))] // FIXME(i586): failure for powidf2
pow! {
f32, 1e-4, __powisf2, all();
f64, 1e-12, __powidf2, all();
@@ -115,7 +115,7 @@ fn $fn() {
};
}
#[cfg(not(x86_no_sse))]
#[cfg(not(x86_no_sse2))]
mod float_mul {
use super::*;
@@ -133,7 +133,7 @@ mod float_mul {
}
#[cfg(f128_enabled)]
#[cfg(not(x86_no_sse))]
#[cfg(not(x86_no_sse2))]
#[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))]
mod float_mul_f128 {
use super::*;
@@ -82,10 +82,10 @@ pub fn configure_aliases(target: &Target) {
}
// Config shorthands
println!("cargo:rustc-check-cfg=cfg(x86_no_sse)");
if target.arch == "x86" && !target.features.iter().any(|f| f == "sse") {
println!("cargo:rustc-check-cfg=cfg(x86_no_sse2)");
if target.arch == "x86" && !target.features.iter().any(|f| f == "sse2") {
// Shorthand to detect i586 targets
println!("cargo:rustc-cfg=x86_no_sse");
println!("cargo:rustc-cfg=x86_no_sse2");
}
/* Not all backends support `f16` and `f128` to the same level on all architectures, so we
@@ -69,7 +69,7 @@ fn bench_one<Op>(c: &mut Criterion, musl_extra: MuslExtra<Op::CFn>)
use anyhow::Context;
use libm_test::CheckOutput;
if cfg!(x86_no_sse) && musl_extra.skip_on_i586 {
if cfg!(x86_no_sse2) && musl_extra.skip_on_i586 {
break;
}
@@ -115,7 +115,7 @@ pub fn default_ulp(ctx: &CheckCtx) -> Option<u32> {
let mut orig_ulp = ulp;
// These have a separate implementation on i586 which is more accurate.
if cfg!(x86_no_sse) {
if cfg!(x86_no_sse2) {
match ctx.fn_ident {
Id::Exp => ulp = 1,
Id::Exp2 => ulp = 1,
@@ -166,8 +166,8 @@ pub fn default_ulp(ctx: &CheckCtx) -> Option<u32> {
Id::Cbrt => ulp = 2,
Id::Cosh => ulp = 2,
Id::Coshf => ulp = 2,
Id::Exp10 if cfg!(x86_no_sse) => ulp = 4,
Id::Exp10f if cfg!(x86_no_sse) => ulp = 4,
Id::Exp10 if cfg!(x86_no_sse2) => ulp = 4,
Id::Exp10f if cfg!(x86_no_sse2) => ulp = 4,
Id::Exp2f => ulp = 1,
Id::Expf => ulp = 1,
Id::Tanh => ulp = 4,
@@ -294,7 +294,7 @@ fn check_int<I: Int>(input: (f32,), actual: I, expected: I, ctx: &CheckCtx) -> C
impl MaybeOverride<(f64,)> for SpecialCase {
fn check_float<F: Float>(input: (f64,), actual: F, expected: F, ctx: &CheckCtx) -> CheckAction {
if cfg!(x86_no_sse)
if cfg!(x86_no_sse2)
&& (ctx.base_name == BaseName::Rint || ctx.base_name == BaseName::Roundeven)
&& (expected - actual).abs() <= F::ONE
&& (expected - actual).abs() > F::ZERO
@@ -533,7 +533,7 @@ fn int_float_common<F1: Float, F2: Float>(
// Our bessel functions blow up with large N values
if ctx.base_name == BaseName::Jn || ctx.base_name == BaseName::Yn {
if cfg!(x86_no_sse) {
if cfg!(x86_no_sse2) {
// Precision is especially bad on i586, not worth checking.
return XFAIL_NOCHECK;
}
+3 -3
View File
@@ -111,10 +111,10 @@ fn emit_optimization_cfg(cfg: &Config) {
/// Provide an alias for common longer config combinations.
fn emit_cfg_shorthands(cfg: &Config) {
println!("cargo:rustc-check-cfg=cfg(x86_no_sse)");
if cfg.target_arch == "x86" && !cfg.target_features.iter().any(|f| f == "sse") {
println!("cargo:rustc-check-cfg=cfg(x86_no_sse2)");
if cfg.target_arch == "x86" && !cfg.target_features.iter().any(|f| f == "sse2") {
// Shorthand to detect i586 targets
println!("cargo:rustc-cfg=x86_no_sse");
println!("cargo:rustc-cfg=x86_no_sse2");
}
}
@@ -49,7 +49,7 @@
}
}
cfg_if! {
if #[cfg(x86_no_sse)] {
if #[cfg(x86_no_sse2)] {
pub use i586::{x87_exp10f, x87_exp10, x87_expf, x87_exp, x87_exp2f, x87_exp2};
}
}
@@ -119,7 +119,7 @@ mod tests {
use super::*;
#[test]
#[cfg_attr(x86_no_sse, ignore = "FIXME(i586): possible incorrect rounding")]
#[cfg_attr(x86_no_sse2, ignore = "FIXME(i586): possible incorrect rounding")]
fn sanity_check() {
assert_eq!(atan2(0.0, 1.0), 0.0);
assert_eq!(atan2(0.0, -1.0), PI);
@@ -208,7 +208,7 @@ mod tests {
#[test]
fn spot_checks() {
if !cfg!(x86_no_sse) {
if !cfg!(x86_no_sse2) {
// Exposes a rounding mode problem. Ignored on i586 because of inaccurate FMA.
assert_biteq!(
cbrt(f64::from_bits(0xf7f792b28f600000)),
@@ -85,7 +85,7 @@
pub fn exp(mut x: f64) -> f64 {
select_implementation! {
name: x87_exp,
use_arch_required: x86_no_sse,
use_arch_required: x86_no_sse2,
args: x,
}
@@ -11,7 +11,7 @@
pub fn exp10(x: f64) -> f64 {
select_implementation! {
name: x87_exp10,
use_arch_required: x86_no_sse,
use_arch_required: x86_no_sse2,
args: x,
}
@@ -11,7 +11,7 @@
pub fn exp10f(x: f32) -> f32 {
select_implementation! {
name: x87_exp10f,
use_arch_required: x86_no_sse,
use_arch_required: x86_no_sse2,
args: x,
}
@@ -326,7 +326,7 @@
pub fn exp2(mut x: f64) -> f64 {
select_implementation! {
name: x87_exp2,
use_arch_required: x86_no_sse,
use_arch_required: x86_no_sse2,
args: x,
}
@@ -77,7 +77,7 @@
pub fn exp2f(mut x: f32) -> f32 {
select_implementation! {
name: x87_exp2f,
use_arch_required: x86_no_sse,
use_arch_required: x86_no_sse2,
args: x,
}
@@ -34,7 +34,7 @@
pub fn expf(mut x: f32) -> f32 {
select_implementation! {
name: x87_expf,
use_arch_required: x86_no_sse,
use_arch_required: x86_no_sse2,
args: x,
}
@@ -14,7 +14,7 @@ pub fn rint_status<F: Float>(x: F) -> FpResult<F> {
// On i386 `force_eval!` must be used to force rounding via storage to memory. Otherwise,
// the excess precission from x87 would cause an incorrect final result.
let force = |x| {
if cfg!(x86_no_sse) && (F::BITS == 32 || F::BITS == 64) {
if cfg!(x86_no_sse2) && (F::BITS == 32 || F::BITS == 64) {
force_eval!(x)
} else {
x
@@ -195,7 +195,7 @@ mod tests {
#[test]
// FIXME(correctness): inaccurate results on i586
#[cfg_attr(x86_no_sse, ignore)]
#[cfg_attr(x86_no_sse2, ignore)]
fn test_near_pi() {
let arg = 3.141592025756836;
let arg = force_eval!(arg);
@@ -228,7 +228,7 @@ pub(crate) fn rem_pio2_large(x: &[f64], y: &mut [f64], e0: i32, prec: usize) ->
// 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))]
#[cfg_attr(x86_no_sse2, inline(never))]
extern "C" fn floor(x: f64) -> f64 {
super::floor(x)
}
@@ -86,7 +86,7 @@ mod tests {
use super::*;
#[test]
#[cfg_attr(x86_no_sse, ignore = "FIXME(i586): possible incorrect rounding")]
#[cfg_attr(x86_no_sse2, ignore = "FIXME(i586): possible incorrect rounding")]
fn test_near_pi() {
let x = f64::from_bits(0x400921fb000FD5DD); // 3.141592026217707
let sx = f64::from_bits(0x3ea50d15ced1a4a2); // 6.273720864039205e-7
@@ -569,7 +569,7 @@ fn check_f32() {
}
assert!(f32::NAN.is_qnan());
// FIXME(rust-lang/rust#115567): x87 use in `is_snan` quiets the sNaN
if !cfg!(x86_no_sse) {
if !cfg!(x86_no_sse2) {
assert!(f32::SNAN.is_snan());
}
@@ -614,7 +614,7 @@ fn check_f64() {
}
assert!(f64::NAN.is_qnan());
// FIXME(rust-lang/rust#115567): x87 use in `is_snan` quiets the sNaN
if !cfg!(x86_no_sse) {
if !cfg!(x86_no_sse2) {
assert!(f64::SNAN.is_snan());
}
@@ -1162,7 +1162,7 @@ fn spot_checks() {
assert_eq!(Hex(f64::NAN).to_string(), "qNaN");
assert_eq!(Hex(f32::NEG_NAN).to_string(), "-qNaN");
assert_eq!(Hex(f64::NEG_NAN).to_string(), "-qNaN");
if !cfg!(x86_no_sse) {
if !cfg!(x86_no_sse2) {
// FIXME(rust-lang/rust#115567): calls quiet the sNaN
assert_eq!(Hex(f32::SNAN).to_string(), "sNaN");
assert_eq!(Hex(f64::SNAN).to_string(), "sNaN");