Skip to content

Commit 2e8b854

Browse files
committed
Move the test to be a standard test.
1 parent 828c5c6 commit 2e8b854

File tree

2 files changed

+25
-8
lines changed

2 files changed

+25
-8
lines changed

testcrate/build.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -775,14 +775,6 @@ fn main() {
775775
(builtins::int::udiv::__udivmodti4(a, b, Some(&mut r)), r)
776776
}");
777777
}
778-
779-
// count leading zeros
780-
gen(|a: MyU64| {
781-
Some((a.0 as usize).leading_zeros())
782-
},
783-
"{
784-
builtins::int::__clzsi2(a as usize) as u32
785-
}");
786778
}
787779

788780
macro_rules! gen_float {
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#![feature(compiler_builtins_lib)]
2+
3+
extern crate compiler_builtins;
4+
5+
use compiler_builtins::int::__clzsi2;
6+
7+
#[test]
8+
fn __clzsi2_test() {
9+
let mut i: usize = core::usize::MAX;
10+
// Check all values above 0
11+
while i > 0 {
12+
assert_eq!(__clzsi2(i) as u32, i.leading_zeros());
13+
i >>= 1;
14+
}
15+
// check 0 also
16+
i = 0;
17+
assert_eq!(__clzsi2(i) as u32, i.leading_zeros());
18+
// double check for bit patterns that aren't just solid 1s
19+
i = 1;
20+
for _ in 0..63 {
21+
assert_eq!(__clzsi2(i) as u32, i.leading_zeros());
22+
i <<= 2;
23+
i += 1;
24+
}
25+
}

0 commit comments

Comments
 (0)