]> git.lizzy.rs Git - rust.git/blob - tests/codegen/slice-iter-len-eq-zero.rs
Auto merge of #107843 - bjorn3:sync_cg_clif-2023-02-09, r=bjorn3
[rust.git] / tests / codegen / slice-iter-len-eq-zero.rs
1 // no-system-llvm
2 // compile-flags: -O
3 // ignore-debug: the debug assertions add extra comparisons
4 #![crate_type = "lib"]
5
6 type Demo = [u8; 3];
7
8 // CHECK-LABEL: @slice_iter_len_eq_zero
9 #[no_mangle]
10 pub fn slice_iter_len_eq_zero(y: std::slice::Iter<'_, Demo>) -> bool {
11     // CHECK-NOT: sub
12     // CHECK: %2 = icmp eq {{i8\*|ptr}} {{%1|%0}}, {{%1|%0}}
13     // CHECK: ret i1 %2
14     y.len() == 0
15 }
16
17 // CHECK-LABEL: @array_into_iter_len_eq_zero
18 #[no_mangle]
19 pub fn array_into_iter_len_eq_zero(y: std::array::IntoIter<Demo, 123>) -> bool {
20     // This should be able to just check that the indexes are equal, and not
21     // need any subtractions or comparisons to handle `start > end`.
22
23     // CHECK-NOT: icmp
24     // CHECK-NOT: sub
25     // CHECK: %1 = icmp eq {{i16|i32|i64}}
26     // CHECK: ret i1 %1
27     y.len() == 0
28 }