Avoid legacy numeric constants

This commit is contained in:
Eduardo Sánchez Muñoz 2024-08-18 13:39:04 +02:00 committed by Amanieu d'Antras
parent c103c015a8
commit f23656fbb6
8 changed files with 33 additions and 37 deletions

View file

@ -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 {
() => {
@ -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,
]
};
}

View file

@ -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")]

View file

@ -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 {
() => {
@ -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,
]
};
}

View file

@ -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);
}
@ -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);
};
@ -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);

View file

@ -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]:
@ -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]:

View file

@ -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},
};
@ -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() {

View file

@ -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);

View file

@ -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() }