Skip to content

Commit

Permalink
Replace all max/min_value() with MAX/MIN
Browse files Browse the repository at this point in the history
  • Loading branch information
faern authored and dtolnay committed Apr 4, 2020
1 parent 03aa622 commit 3bd56ed
Show file tree
Hide file tree
Showing 9 changed files with 317 additions and 317 deletions.
490 changes: 245 additions & 245 deletions crates/core_arch/src/mips/msa.rs

Large diffs are not rendered by default.

42 changes: 21 additions & 21 deletions crates/core_arch/src/powerpc/altivec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2045,32 +2045,32 @@ mod tests {
}

test_vec_avg! { test_vec_avg_i32x4, i32x4,
[i32::min_value(), i32::max_value(), 1, -1],
[i32::MIN, i32::MAX, 1, -1],
[-1, 1, 1, -1],
[-1073741824, 1073741824, 1, -1] }

test_vec_avg! { test_vec_avg_u32x4, u32x4,
[u32::max_value(), 0, 1, 2],
[u32::MAX, 0, 1, 2],
[2, 1, 0, 0],
[2147483649, 1, 1, 1] }

test_vec_avg! { test_vec_avg_i16x8, i16x8,
[i16::min_value(), i16::max_value(), 1, -1, 0, 0, 0, 0],
[i16::MIN, i16::MAX, 1, -1, 0, 0, 0, 0],
[-1, 1, 1, -1, 0, 0, 0, 0],
[-16384, 16384, 1, -1, 0, 0, 0, 0] }

test_vec_avg! { test_vec_avg_u16x8, u16x8,
[u16::max_value(), 0, 1, 2, 0, 0, 0, 0],
[u16::MAX, 0, 1, 2, 0, 0, 0, 0],
[2, 1, 0, 0, 0, 0, 0, 0],
[32769, 1, 1, 1, 0, 0, 0, 0] }

test_vec_avg! { test_vec_avg_i8x16, i8x16,
[i8::min_value(), i8::max_value(), 1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[i8::MIN, i8::MAX, 1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[-1, 1, 1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[-64, 64, 1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }

test_vec_avg! { test_vec_avg_u8x16, u8x16,
[u8::max_value(), 0, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[u8::MAX, 0, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[129, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }

Expand All @@ -2081,36 +2081,36 @@ mod tests {
}

test_vec_adds! { test_vec_adds_i32x4, i32x4,
[i32::min_value(), i32::max_value(), 1, -1],
[i32::MIN, i32::MAX, 1, -1],
[-1, 1, 1, -1],
[i32::min_value(), i32::max_value(), 2, -2] }
[i32::MIN, i32::MAX, 2, -2] }

test_vec_adds! { test_vec_adds_u32x4, u32x4,
[u32::max_value(), 0, 1, 2],
[u32::MAX, 0, 1, 2],
[2, 1, 0, 0],
[u32::max_value(), 1, 1, 2] }
[u32::MAX, 1, 1, 2] }

test_vec_adds! { test_vec_adds_i16x8, i16x8,
[i16::min_value(), i16::max_value(), 1, -1, 0, 0, 0, 0],
[i16::MIN, i16::MAX, 1, -1, 0, 0, 0, 0],
[-1, 1, 1, -1, 0, 0, 0, 0],
[i16::min_value(), i16::max_value(), 2, -2, 0, 0, 0, 0] }
[i16::MIN, i16::MAX, 2, -2, 0, 0, 0, 0] }

test_vec_adds! { test_vec_adds_u16x8, u16x8,
[u16::max_value(), 0, 1, 2, 0, 0, 0, 0],
[u16::MAX, 0, 1, 2, 0, 0, 0, 0],
[2, 1, 0, 0, 0, 0, 0, 0],
[u16::max_value(), 1, 1, 2, 0, 0, 0, 0] }
[u16::MAX, 1, 1, 2, 0, 0, 0, 0] }

test_vec_adds! { test_vec_adds_i8x16, i8x16,
[i8::min_value(), i8::max_value(), 1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[i8::MIN, i8::MAX, 1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[-1, 1, 1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[i8::min_value(), i8::max_value(), 2, -2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }
[i8::MIN, i8::MAX, 2, -2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }

test_vec_adds! { test_vec_adds_u8x16, u8x16,
[u8::max_value(), 0, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[u8::MAX, 0, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[u8::max_value(), 1, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }
[u8::MAX, 1, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }

test_vec_2! { test_vec_addc, vec_addc, u32x4, [u32::max_value(), 0, 0, 0], [1, 1, 1, 1], [1, 0, 0, 0] }
test_vec_2! { test_vec_addc, vec_addc, u32x4, [u32::MAX, 0, 0, 0], [1, 1, 1, 1], [1, 0, 0, 0] }

macro_rules! test_vec_abs {
{ $name: ident, $ty: ident, $a: expr, $d: expr } => {
Expand Down Expand Up @@ -2482,9 +2482,9 @@ mod tests {
));
let b: vector_signed_short = transmute(i16x8::new(256, 256, 256, 256, 256, 256, 256, 256));
let c: vector_signed_short =
transmute(i16x8::new(0, 1, 2, 3, 4, 5, 6, i16::max_value() - 1));
transmute(i16x8::new(0, 1, 2, 3, 4, 5, 6, i16::MAX - 1));

let d = i16x8::new(0, 3, 6, 9, 12, 15, 18, i16::max_value());
let d = i16x8::new(0, 3, 6, 9, 12, 15, 18, i16::MAX);

assert_eq!(d, transmute(vec_mradds(a, b, c)));
}
Expand Down
52 changes: 26 additions & 26 deletions crates/core_arch/src/wasm32/simd128.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1862,23 +1862,23 @@ pub mod tests {

test_i32x4_add => {
[0i32, 0, 0, 0] (+ | i32x4_add) [1, 2, 3, 4],
[1i32, 1283, i32::max_value(), i32::min_value()]
[1i32, 1283, i32::MAX, i32::MIN]
(+ | i32x4_add)
[i32::max_value(); 4],
[i32::MAX; 4],
}

test_i32x4_sub => {
[0i32, 0, 0, 0] (- | i32x4_sub) [1, 2, 3, 4],
[1i32, 1283, i32::max_value(), i32::min_value()]
[1i32, 1283, i32::MAX, i32::MIN]
(- | i32x4_sub)
[i32::max_value(); 4],
[i32::MAX; 4],
}

test_i32x4_mul => {
[0i32, 0, 0, 0] (* | i32x4_mul) [1, 2, 3, 4],
[1i32, 1283, i32::max_value(), i32::min_value()]
[1i32, 1283, i32::MAX, i32::MIN]
(* | i32x4_mul)
[i32::max_value(); 4],
[i32::MAX; 4],
}

// TODO: test_i64x2_add
Expand All @@ -1904,7 +1904,7 @@ pub mod tests {

test_i32x4_neg => {
(- | i32x4_neg) [1i32, 2, 3, 4],
(- | i32x4_neg) [i32::min_value(), i32::max_value(), 0, 4],
(- | i32x4_neg) [i32::MIN, i32::MAX, 0, 4],
}

// TODO: test_i64x2_neg
Expand Down Expand Up @@ -2042,43 +2042,43 @@ pub mod tests {
//
//
// test_bops!(i8x16[i8; 16] | shl[i8x16_shl_test]:
// ([0, -1, 2, 3, 4, 5, 6, i8::max_value(), 1, 1, 1, 1, 1, 1, 1, 1], 1) =>
// ([0, -1, 2, 3, 4, 5, 6, i8::MAX, 1, 1, 1, 1, 1, 1, 1, 1], 1) =>
// [0, -2, 4, 6, 8, 10, 12, -2, 2, 2, 2, 2, 2, 2, 2, 2]);
// test_bops!(i16x8[i16; 8] | shl[i16x8_shl_test]:
// ([0, -1, 2, 3, 4, 5, 6, i16::max_value()], 1) =>
// ([0, -1, 2, 3, 4, 5, 6, i16::MAX], 1) =>
// [0, -2, 4, 6, 8, 10, 12, -2]);
// test_bops!(i32x4[i32; 4] | shl[i32x4_shl_test]:
// ([0, -1, 2, 3], 1) => [0, -2, 4, 6]);
// test_bops!(i64x2[i64; 2] | shl[i64x2_shl_test]:
// ([0, -1], 1) => [0, -2]);
//
// test_bops!(i8x16[i8; 16] | shr_s[i8x16_shr_s_test]:
// ([0, -1, 2, 3, 4, 5, 6, i8::max_value(), 1, 1, 1, 1, 1, 1, 1, 1], 1) =>
// ([0, -1, 2, 3, 4, 5, 6, i8::MAX, 1, 1, 1, 1, 1, 1, 1, 1], 1) =>
// [0, -1, 1, 1, 2, 2, 3, 63, 0, 0, 0, 0, 0, 0, 0, 0]);
// test_bops!(i16x8[i16; 8] | shr_s[i16x8_shr_s_test]:
// ([0, -1, 2, 3, 4, 5, 6, i16::max_value()], 1) =>
// [0, -1, 1, 1, 2, 2, 3, i16::max_value() / 2]);
// ([0, -1, 2, 3, 4, 5, 6, i16::MAX], 1) =>
// [0, -1, 1, 1, 2, 2, 3, i16::MAX / 2]);
// test_bops!(i32x4[i32; 4] | shr_s[i32x4_shr_s_test]:
// ([0, -1, 2, 3], 1) => [0, -1, 1, 1]);
// test_bops!(i64x2[i64; 2] | shr_s[i64x2_shr_s_test]:
// ([0, -1], 1) => [0, -1]);
//
// test_bops!(i8x16[i8; 16] | shr_u[i8x16_uhr_u_test]:
// ([0, -1, 2, 3, 4, 5, 6, i8::max_value(), 1, 1, 1, 1, 1, 1, 1, 1], 1) =>
// [0, i8::max_value(), 1, 1, 2, 2, 3, 63, 0, 0, 0, 0, 0, 0, 0, 0]);
// ([0, -1, 2, 3, 4, 5, 6, i8::MAX, 1, 1, 1, 1, 1, 1, 1, 1], 1) =>
// [0, i8::MAX, 1, 1, 2, 2, 3, 63, 0, 0, 0, 0, 0, 0, 0, 0]);
// test_bops!(i16x8[i16; 8] | shr_u[i16x8_uhr_u_test]:
// ([0, -1, 2, 3, 4, 5, 6, i16::max_value()], 1) =>
// [0, i16::max_value(), 1, 1, 2, 2, 3, i16::max_value() / 2]);
// ([0, -1, 2, 3, 4, 5, 6, i16::MAX], 1) =>
// [0, i16::MAX, 1, 1, 2, 2, 3, i16::MAX / 2]);
// test_bops!(i32x4[i32; 4] | shr_u[i32x4_uhr_u_test]:
// ([0, -1, 2, 3], 1) => [0, i32::max_value(), 1, 1]);
// ([0, -1, 2, 3], 1) => [0, i32::MAX, 1, 1]);
// test_bops!(i64x2[i64; 2] | shr_u[i64x2_uhr_u_test]:
// ([0, -1], 1) => [0, i64::max_value()]);
// ([0, -1], 1) => [0, i64::MAX]);
//
// #[wasm_bindgen_test]
// fn v128_bitwise_logical_ops() {
// unsafe {
// let a: [u32; 4] = [u32::max_value(), 0, u32::max_value(), 0];
// let b: [u32; 4] = [u32::max_value(); 4];
// let a: [u32; 4] = [u32::MAX, 0, u32::MAX, 0];
// let b: [u32; 4] = [u32::MAX; 4];
// let c: [u32; 4] = [0; 4];
//
// let vec_a: v128 = transmute(a);
Expand Down Expand Up @@ -2312,8 +2312,8 @@ pub mod tests {
// f32x4_convert_u_i32x4
// | convert_u_i32x4
// | f32x4
// | [u32::max_value(), 2, 3, 4],
// [u32::max_value() as f32, 2., 3., 4.]
// | [u32::MAX, 2, 3, 4],
// [u32::MAX as f32, 2., 3., 4.]
// );
// test_conv!(
// f64x2_convert_s_i64x2 | convert_s_i64x2 | f64x2 | [1_i64, 2],
Expand All @@ -2323,12 +2323,12 @@ pub mod tests {
// f64x2_convert_u_i64x2
// | convert_u_i64x2
// | f64x2
// | [u64::max_value(), 2],
// | [u64::MAX, 2],
// [18446744073709552000.0, 2.]
// );
//
// // FIXME: this fails, and produces -2147483648 instead of saturating at
// // i32::max_value() test_conv!(i32x4_trunc_s_f32x4_sat | trunc_s_f32x4_sat
// // | i32x4 | [1_f32, 2., (i32::max_value() as f32 + 1.), 4.],
// // [1_i32, 2, i32::max_value(), 4]); FIXME: add other saturating tests
// // i32::MAX test_conv!(i32x4_trunc_s_f32x4_sat | trunc_s_f32x4_sat
// // | i32x4 | [1_f32, 2., (i32::MAX as f32 + 1.), 4.],
// // [1_i32, 2, i32::MAX, 4]); FIXME: add other saturating tests
}
6 changes: 3 additions & 3 deletions crates/core_arch/src/x86/adx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ mod tests {
#[test]
fn test_addcarry_u32() {
unsafe {
let a = u32::max_value();
let a = u32::MAX;
let mut out = 0;

let r = _addcarry_u32(0, a, 1, &mut out);
Expand Down Expand Up @@ -86,7 +86,7 @@ mod tests {

#[simd_test(enable = "adx")]
unsafe fn test_addcarryx_u32() {
let a = u32::max_value();
let a = u32::MAX;
let mut out = 0;

let r = _addcarryx_u32(0, a, 1, &mut out);
Expand Down Expand Up @@ -127,7 +127,7 @@ mod tests {
#[test]
fn test_subborrow_u32() {
unsafe {
let a = u32::max_value();
let a = u32::MAX;
let mut out = 0;

let r = _subborrow_u32(0, 0, 1, &mut out);
Expand Down
26 changes: 13 additions & 13 deletions crates/core_arch/src/x86/mmx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -552,17 +552,17 @@ mod tests {
#[simd_test(enable = "mmx")]
unsafe fn test_mm_add_pi16() {
let a = _mm_setr_pi16(-1, -1, 1, 1);
let b = _mm_setr_pi16(i16::min_value() + 1, 30001, -30001, i16::max_value() - 1);
let e = _mm_setr_pi16(i16::min_value(), 30000, -30000, i16::max_value());
let b = _mm_setr_pi16(i16::MIN + 1, 30001, -30001, i16::MAX - 1);
let e = _mm_setr_pi16(i16::MIN, 30000, -30000, i16::MAX);
assert_eq_m64(e, _mm_add_pi16(a, b));
assert_eq_m64(e, _m_paddw(a, b));
}

#[simd_test(enable = "mmx")]
unsafe fn test_mm_add_pi32() {
let a = _mm_setr_pi32(1, -1);
let b = _mm_setr_pi32(i32::max_value() - 1, i32::min_value() + 1);
let e = _mm_setr_pi32(i32::max_value(), i32::min_value());
let b = _mm_setr_pi32(i32::MAX - 1, i32::MIN + 1);
let e = _mm_setr_pi32(i32::MAX, i32::MIN);
assert_eq_m64(e, _mm_add_pi32(a, b));
assert_eq_m64(e, _m_paddd(a, b));
}
Expand All @@ -571,7 +571,7 @@ mod tests {
unsafe fn test_mm_adds_pi8() {
let a = _mm_setr_pi8(-100, -1, 1, 100, -1, 0, 1, 0);
let b = _mm_setr_pi8(-100, 1, -1, 100, 0, -1, 0, 1);
let e = _mm_setr_pi8(i8::min_value(), 0, 0, i8::max_value(), -1, -1, 1, 1);
let e = _mm_setr_pi8(i8::MIN, 0, 0, i8::MAX, -1, -1, 1, 1);
assert_eq_m64(e, _mm_adds_pi8(a, b));
assert_eq_m64(e, _m_paddsb(a, b));
}
Expand All @@ -580,7 +580,7 @@ mod tests {
unsafe fn test_mm_adds_pi16() {
let a = _mm_setr_pi16(-32000, 32000, 4, 0);
let b = _mm_setr_pi16(-32000, 32000, -5, 1);
let e = _mm_setr_pi16(i16::min_value(), i16::max_value(), -1, 1);
let e = _mm_setr_pi16(i16::MIN, i16::MAX, -1, 1);
assert_eq_m64(e, _mm_adds_pi16(a, b));
assert_eq_m64(e, _m_paddsw(a, b));
}
Expand All @@ -589,7 +589,7 @@ mod tests {
unsafe fn test_mm_adds_pu8() {
let a = _mm_setr_pi8(0, 1, 2, 3, 4, 5, 6, 200u8 as i8);
let b = _mm_setr_pi8(0, 10, 20, 30, 40, 50, 60, 200u8 as i8);
let e = _mm_setr_pi8(0, 11, 22, 33, 44, 55, 66, u8::max_value() as i8);
let e = _mm_setr_pi8(0, 11, 22, 33, 44, 55, 66, u8::MAX as i8);
assert_eq_m64(e, _mm_adds_pu8(a, b));
assert_eq_m64(e, _m_paddusb(a, b));
}
Expand All @@ -598,7 +598,7 @@ mod tests {
unsafe fn test_mm_adds_pu16() {
let a = _mm_setr_pi16(0, 1, 2, 60000u16 as i16);
let b = _mm_setr_pi16(0, 10, 20, 60000u16 as i16);
let e = _mm_setr_pi16(0, 11, 22, u16::max_value() as i16);
let e = _mm_setr_pi16(0, 11, 22, u16::MAX as i16);
assert_eq_m64(e, _mm_adds_pu16(a, b));
assert_eq_m64(e, _m_paddusw(a, b));
}
Expand Down Expand Up @@ -633,11 +633,11 @@ mod tests {
#[simd_test(enable = "mmx")]
unsafe fn test_mm_subs_pi8() {
let a = _mm_setr_pi8(-100, 100, 0, 0, 0, 0, -5, 5);
let b = _mm_setr_pi8(100, -100, i8::min_value(), 127, -1, 1, 3, -3);
let b = _mm_setr_pi8(100, -100, i8::MIN, 127, -1, 1, 3, -3);
let e = _mm_setr_pi8(
i8::min_value(),
i8::max_value(),
i8::max_value(),
i8::MIN,
i8::MAX,
i8::MAX,
-127,
1,
-1,
Expand All @@ -652,7 +652,7 @@ mod tests {
unsafe fn test_mm_subs_pi16() {
let a = _mm_setr_pi16(-20000, 20000, 0, 0);
let b = _mm_setr_pi16(20000, -20000, -1, 1);
let e = _mm_setr_pi16(i16::min_value(), i16::max_value(), 1, -1);
let e = _mm_setr_pi16(i16::MIN, i16::MAX, 1, -1);
assert_eq_m64(e, _mm_subs_pi16(a, b));
assert_eq_m64(e, _m_psubsw(a, b));
}
Expand Down
6 changes: 3 additions & 3 deletions crates/core_arch/src/x86/sse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3414,7 +3414,7 @@ mod tests {
#[simd_test(enable = "sse")]
unsafe fn test_mm_cvtss_si32() {
let inputs = &[42.0f32, -3.1, 4.0e10, 4.0e-20, NAN, 2147483500.1];
let result = &[42i32, -3, i32::min_value(), 0, i32::min_value(), 2147483520];
let result = &[42i32, -3, i32::MIN, 0, i32::MIN, 2147483520];
for i in 0..inputs.len() {
let x = _mm_setr_ps(inputs[i], 1.0, 3.0, 4.0);
let e = result[i];
Expand All @@ -3436,9 +3436,9 @@ mod tests {
(-34.5, -34),
(10.999, 10),
(-5.99, -5),
(4.0e10, i32::min_value()),
(4.0e10, i32::MIN),
(4.0e-10, 0),
(NAN, i32::min_value()),
(NAN, i32::MIN),
(2147483500.1, 2147483520),
];
for i in 0..inputs.len() {
Expand Down
6 changes: 3 additions & 3 deletions crates/core_arch/src/x86_64/adx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ mod tests {
#[test]
fn test_addcarry_u64() {
unsafe {
let a = u64::max_value();
let a = u64::MAX;
let mut out = 0;

let r = _addcarry_u64(0, a, 1, &mut out);
Expand Down Expand Up @@ -86,7 +86,7 @@ mod tests {

#[simd_test(enable = "adx")]
unsafe fn test_addcarryx_u64() {
let a = u64::max_value();
let a = u64::MAX;
let mut out = 0;

let r = _addcarry_u64(0, a, 1, &mut out);
Expand Down Expand Up @@ -117,7 +117,7 @@ mod tests {
#[test]
fn test_subborrow_u64() {
unsafe {
let a = u64::max_value();
let a = u64::MAX;
let mut out = 0;

let r = _subborrow_u64(0, 0, 1, &mut out);
Expand Down
4 changes: 2 additions & 2 deletions crates/std_detect/src/detect/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,12 @@ impl Cache {
/// Creates an uninitialized cache.
#[allow(clippy::declare_interior_mutable_const)]
const fn uninitialized() -> Self {
Cache(AtomicUsize::new(usize::max_value()))
Cache(AtomicUsize::new(usize::MAX))
}
/// Is the cache uninitialized?
#[inline]
pub(crate) fn is_uninitialized(&self) -> bool {
self.0.load(Ordering::SeqCst) == usize::max_value()
self.0.load(Ordering::SeqCst) == usize::MAX
}

/// Is the `bit` in the cache set?
Expand Down
Loading

0 comments on commit 3bd56ed

Please sign in to comment.