Skip to content

Commit 1ec628d

Browse files
committed
Auto merge of #114850 - khei4:khei4/trailing_zero_codegen, r=nikic
add codegen test for `trailing_zeros` comparison This PR add codegen test for #107554 (comment) Fixes #107554.
2 parents 2bc7929 + 8d514f2 commit 1ec628d

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

tests/codegen/trailing_zeros.rs

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// compile-flags: -O
2+
// min-llvm-version: 17
3+
4+
#![crate_type = "lib"]
5+
6+
// CHECK-LABEL: @trailing_zeros_ge
7+
#[no_mangle]
8+
pub fn trailing_zeros_ge(val: u32) -> bool {
9+
// CHECK: %[[AND:.*]] = and i32 %val, 7
10+
// CHECK: %[[ICMP:.*]] = icmp eq i32 %[[AND]], 0
11+
// CHECK: ret i1 %[[ICMP]]
12+
val.trailing_zeros() >= 3
13+
}
14+
15+
// CHECK-LABEL: @trailing_zeros_gt
16+
#[no_mangle]
17+
pub fn trailing_zeros_gt(val: u64) -> bool {
18+
// CHECK: %[[AND:.*]] = and i64 %val, 15
19+
// CHECK: %[[ICMP:.*]] = icmp eq i64 %[[AND]], 0
20+
// CHECK: ret i1 %[[ICMP]]
21+
val.trailing_zeros() > 3
22+
}

0 commit comments

Comments
 (0)