Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add codegen test for trailing_zeros comparison #114850

Merged
merged 1 commit into from
Aug 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions tests/codegen/trailing_zeros.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// compile-flags: -O
khei4 marked this conversation as resolved.
Show resolved Hide resolved
// min-llvm-version: 17

#![crate_type = "lib"]

// CHECK-LABEL: @trailing_zeros_ge
#[no_mangle]
pub fn trailing_zeros_ge(val: u32) -> bool {
// CHECK: %[[AND:.*]] = and i32 %val, 7
// CHECK: %[[ICMP:.*]] = icmp eq i32 %[[AND]], 0
// CHECK: ret i1 %[[ICMP]]
val.trailing_zeros() >= 3
}

// CHECK-LABEL: @trailing_zeros_gt
#[no_mangle]
pub fn trailing_zeros_gt(val: u64) -> bool {
// CHECK: %[[AND:.*]] = and i64 %val, 15
// CHECK: %[[ICMP:.*]] = icmp eq i64 %[[AND]], 0
// CHECK: ret i1 %[[ICMP]]
val.trailing_zeros() > 3
}
Loading