Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid legacy numeric constants #1632

Merged
merged 1 commit into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions crates/core_arch/src/aarch64/test_support.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::core_arch::{aarch64::neon::*, arm_shared::*, simd::*};
use std::{i16, i32, i8, mem::transmute, u16, u32, u8, vec::Vec};
use std::{mem::transmute, vec::Vec};

macro_rules! V_u64 {
() => {
Expand All @@ -23,11 +23,11 @@ macro_rules! V_f64 {
-1.0f64,
1.2f64,
2.4f64,
std::f64::MAX,
std::f64::MIN,
std::f64::INFINITY,
std::f64::NEG_INFINITY,
std::f64::NAN,
f64::MAX,
f64::MIN,
f64::INFINITY,
f64::NEG_INFINITY,
f64::NAN,
]
};
}
Expand Down
2 changes: 1 addition & 1 deletion crates/core_arch/src/arm_shared/neon/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10124,7 +10124,7 @@ mod tests {
use crate::core_arch::arm::*;
use crate::core_arch::arm_shared::test_support::*;
use crate::core_arch::simd::*;
use std::{i16, i32, i8, mem::transmute, u16, u32, u8, vec::Vec};
use std::{mem::transmute, vec::Vec};
use stdarch_test::simd_test;

#[simd_test(enable = "neon")]
Expand Down
12 changes: 6 additions & 6 deletions crates/core_arch/src/arm_shared/test_support.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::core_arch::arm::*;
use crate::core_arch::aarch64::*;

use crate::core_arch::simd::*;
use std::{i16, i32, i8, mem::transmute, u16, u32, u8, vec::Vec};
use std::{mem::transmute, vec::Vec};

macro_rules! V_u8 {
() => {
Expand Down Expand Up @@ -100,11 +100,11 @@ macro_rules! V_f32 {
-1.0f32,
1.2f32,
2.4f32,
std::f32::MAX,
std::f32::MIN,
std::f32::INFINITY,
std::f32::NEG_INFINITY,
std::f32::NAN,
f32::MAX,
f32::MIN,
f32::INFINITY,
f32::NEG_INFINITY,
f32::NAN,
]
};
}
Expand Down
12 changes: 3 additions & 9 deletions crates/core_arch/src/powerpc/altivec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4680,7 +4680,7 @@ mod tests {
let a: vector_float = transmute(f32x4::new($($a),+));

let d: vector_float = transmute(f32x4::new($($d),+));
let r = transmute(vec_cmple(vec_abs(vec_sub($fn(a), d)), vec_splats(std::f32::EPSILON)));
let r = transmute(vec_cmple(vec_abs(vec_sub($fn(a), d)), vec_splats(f32::EPSILON)));
let e = m32x4::new(true, true, true, true);
assert_eq!(e, r);
}
Expand Down Expand Up @@ -6610,10 +6610,7 @@ mod tests {
let r8: vector_float = transmute(f32x4::new(0.0, 536870900.0, 536870900.0, 5.25));

let check = |a, b| {
let r = transmute(vec_cmple(
vec_abs(vec_sub(a, b)),
vec_splats(std::f32::EPSILON),
));
let r = transmute(vec_cmple(vec_abs(vec_sub(a, b)), vec_splats(f32::EPSILON)));
let e = m32x4::new(true, true, true, true);
assert_eq!(e, r);
};
Expand Down Expand Up @@ -6662,10 +6659,7 @@ mod tests {
let r8: vector_float = transmute(f32x4::new(-268435460.0, 268435460.0, 268435460.0, 5.25));

let check = |a, b| {
let r = transmute(vec_cmple(
vec_abs(vec_sub(a, b)),
vec_splats(std::f32::EPSILON),
));
let r = transmute(vec_cmple(vec_abs(vec_sub(a, b)), vec_splats(f32::EPSILON)));
println!("{:?} {:?}", a, b);
let e = m32x4::new(true, true, true, true);
assert_eq!(e, r);
Expand Down
16 changes: 8 additions & 8 deletions crates/core_arch/src/wasm32/simd128.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5646,13 +5646,13 @@ mod tests {
test_bop!(f32x4[f32; 4] | f32x4_min[f32x4_min_test]:
([0., -1., 7., 8.], [1., -3., -4., 10.]) => [0., -3., -4., 8.]);
test_bop!(f32x4[f32; 4] | f32x4_min[f32x4_min_test_nan]:
([0., -1., 7., 8.], [1., -3., -4., std::f32::NAN])
=> [0., -3., -4., std::f32::NAN]);
([0., -1., 7., 8.], [1., -3., -4., f32::NAN])
=> [0., -3., -4., f32::NAN]);
test_bop!(f32x4[f32; 4] | f32x4_max[f32x4_max_test]:
([0., -1., 7., 8.], [1., -3., -4., 10.]) => [1., -1., 7., 10.]);
test_bop!(f32x4[f32; 4] | f32x4_max[f32x4_max_test_nan]:
([0., -1., 7., 8.], [1., -3., -4., std::f32::NAN])
=> [1., -1., 7., std::f32::NAN]);
([0., -1., 7., 8.], [1., -3., -4., f32::NAN])
=> [1., -1., 7., f32::NAN]);
test_bop!(f32x4[f32; 4] | f32x4_add[f32x4_add_test]:
([0., -1., 7., 8.], [1., -3., -4., 10.]) => [1., -4., 3., 18.]);
test_bop!(f32x4[f32; 4] | f32x4_sub[f32x4_sub_test]:
Expand All @@ -5667,13 +5667,13 @@ mod tests {
test_bop!(f64x2[f64; 2] | f64x2_min[f64x2_min_test]:
([0., -1.], [1., -3.]) => [0., -3.]);
test_bop!(f64x2[f64; 2] | f64x2_min[f64x2_min_test_nan]:
([7., 8.], [-4., std::f64::NAN])
=> [ -4., std::f64::NAN]);
([7., 8.], [-4., f64::NAN])
=> [ -4., f64::NAN]);
test_bop!(f64x2[f64; 2] | f64x2_max[f64x2_max_test]:
([0., -1.], [1., -3.]) => [1., -1.]);
test_bop!(f64x2[f64; 2] | f64x2_max[f64x2_max_test_nan]:
([7., 8.], [ -4., std::f64::NAN])
=> [7., std::f64::NAN]);
([7., 8.], [ -4., f64::NAN])
=> [7., f64::NAN]);
test_bop!(f64x2[f64; 2] | f64x2_add[f64x2_add_test]:
([0., -1.], [1., -3.]) => [1., -4.]);
test_bop!(f64x2[f64; 2] | f64x2_sub[f64x2_sub_test]:
Expand Down
6 changes: 3 additions & 3 deletions crates/core_arch/src/x86/sha.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,7 @@ pub unsafe fn _mm_sha256rnds2_epu32(a: __m128i, b: __m128i, k: __m128i) -> __m12
#[cfg(test)]
mod tests {
use std::{
f32,
f64::{self, NAN},
i32,
f32, f64,
mem::{self, transmute},
};

Expand All @@ -133,6 +131,8 @@ mod tests {
};
use stdarch_test::simd_test;

const NAN: f64 = f64::NAN;

#[simd_test(enable = "sha")]
#[allow(overflowing_literals)]
unsafe fn test_mm_sha1msg1_epu32() {
Expand Down
4 changes: 3 additions & 1 deletion crates/core_arch/src/x86/sse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2002,11 +2002,13 @@ pub unsafe fn _mm_stream_ps(mem_addr: *mut f32, a: __m128) {
#[cfg(test)]
mod tests {
use crate::{hint::black_box, mem::transmute, ptr};
use std::{boxed, f32::NAN};
use std::boxed;
use stdarch_test::simd_test;

use crate::core_arch::{simd::*, x86::*};

const NAN: f32 = f32::NAN;

#[simd_test(enable = "sse")]
unsafe fn test_mm_add_ps() {
let a = _mm_setr_ps(-1.0, 5.0, 0.0, -10.0);
Expand Down
6 changes: 3 additions & 3 deletions crates/core_arch/src/x86/sse2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3046,14 +3046,14 @@ mod tests {
hint::black_box,
};
use std::{
boxed, f32,
f64::{self, NAN},
i32,
boxed, f32, f64,
mem::{self, transmute},
ptr,
};
use stdarch_test::simd_test;

const NAN: f64 = f64::NAN;

#[test]
fn test_mm_pause() {
unsafe { _mm_pause() }
Expand Down