]> git.lizzy.rs Git - rust.git/blob - tests/codegen/slice-as_chunks.rs
Rollup merge of #107190 - fmease:fix-81698, r=compiler-errors
[rust.git] / tests / codegen / slice-as_chunks.rs
1 // no-system-llvm
2 // compile-flags: -O
3 // only-64bit (because the LLVM type of i64 for usize shows up)
4 // ignore-debug: the debug assertions get in the way
5
6 #![crate_type = "lib"]
7 #![feature(slice_as_chunks)]
8
9 // CHECK-LABEL: @chunks4
10 #[no_mangle]
11 pub fn chunks4(x: &[u8]) -> &[[u8; 4]] {
12     // CHECK-NEXT: start:
13     // CHECK-NEXT: lshr i64 %x.1, 2
14     // CHECK-NOT: shl
15     // CHECK-NOT: mul
16     // CHECK-NOT: udiv
17     // CHECK-NOT: urem
18     // CHECK: ret
19     x.as_chunks().0
20 }
21
22 // CHECK-LABEL: @chunks4_with_remainder
23 #[no_mangle]
24 pub fn chunks4_with_remainder(x: &[u8]) -> (&[[u8; 4]], &[u8]) {
25     // CHECK: and i64 %x.1, -4
26     // CHECK: and i64 %x.1, 3
27     // CHECK: lshr exact
28     // CHECK-NOT: mul
29     // CHECK-NOT: udiv
30     // CHECK-NOT: urem
31     // CHECK: ret
32     x.as_chunks()
33 }