Skip to content

Commit 15e97bd

Browse files
authored
Rollup merge of #137826 - karolzwolak:looping_over_ne_bytes_133528, r=DianQK
test(codegen): add looping_over_ne_bytes test for #133528 Adds test for #133528. I renamed the function to `looping_over_ne_bytes` to better reflect that it is doing. I also set the min llvm version to 20 as this was presumably a llvm bug that was fixed in version 20. I didn't tie the test to any specific architecture, as we are testing llvm output.
2 parents d818c1d + 107d7ef commit 15e97bd

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//@ compile-flags: -Copt-level=3
2+
//@ min-llvm-version: 20
3+
#![crate_type = "lib"]
4+
5+
/// Ensure the function is properly optimized
6+
/// In the issue #133528, the function was not getting optimized
7+
/// whereas, a version with `bytes` wrapped into a `black_box` was optimized
8+
/// It was probably a LLVM bug that was fixed in LLVM 20
9+
10+
// CHECK-LABEL: @looping_over_ne_bytes
11+
// CHECK: icmp eq i64 %input, -1
12+
// CHECK-NEXT: ret i1
13+
#[no_mangle]
14+
fn looping_over_ne_bytes(input: u64) -> bool {
15+
let bytes = input.to_ne_bytes();
16+
bytes.iter().all(|x| *x == !0)
17+
}

0 commit comments

Comments
 (0)