Move the test to be a standard test.
This commit is contained in:
parent
828c5c6d5f
commit
2e8b85439f
|
@ -775,14 +775,6 @@ fn main() {
|
|||
(builtins::int::udiv::__udivmodti4(a, b, Some(&mut r)), r)
|
||||
}");
|
||||
}
|
||||
|
||||
// count leading zeros
|
||||
gen(|a: MyU64| {
|
||||
Some((a.0 as usize).leading_zeros())
|
||||
},
|
||||
"{
|
||||
builtins::int::__clzsi2(a as usize) as u32
|
||||
}");
|
||||
}
|
||||
|
||||
macro_rules! gen_float {
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
#![feature(compiler_builtins_lib)]
|
||||
|
||||
extern crate compiler_builtins;
|
||||
|
||||
use compiler_builtins::int::__clzsi2;
|
||||
|
||||
#[test]
|
||||
fn __clzsi2_test() {
|
||||
let mut i: usize = core::usize::MAX;
|
||||
// Check all values above 0
|
||||
while i > 0 {
|
||||
assert_eq!(__clzsi2(i) as u32, i.leading_zeros());
|
||||
i >>= 1;
|
||||
}
|
||||
// check 0 also
|
||||
i = 0;
|
||||
assert_eq!(__clzsi2(i) as u32, i.leading_zeros());
|
||||
// double check for bit patterns that aren't just solid 1s
|
||||
i = 1;
|
||||
for _ in 0..63 {
|
||||
assert_eq!(__clzsi2(i) as u32, i.leading_zeros());
|
||||
i <<= 2;
|
||||
i += 1;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue