]> git.lizzy.rs Git - rust.git/blob - tests/codegen/slice_as_from_ptr_range.rs
Auto merge of #101138 - Rejyr:diagnostic-migration-rustc-lint-pt2, r=davidtwco
[rust.git] / tests / codegen / slice_as_from_ptr_range.rs
1 // compile-flags: -O
2 // only-64bit (because we're using [ui]size)
3 // ignore-debug (because the assertions get in the way)
4 // min-llvm-version: 15.0 (because this is a relatively new instcombine)
5
6 #![crate_type = "lib"]
7 #![feature(slice_from_ptr_range)]
8
9 // This is intentionally using a non-power-of-two array length,
10 // as that's where the optimization differences show up
11
12 // CHECK-LABEL: @flatten_via_ptr_range
13 #[no_mangle]
14 pub fn flatten_via_ptr_range(slice_of_arrays: &[[i32; 13]]) -> &[i32] {
15     // CHECK-NOT: lshr
16     // CHECK-NOT: udiv
17     // CHECK: mul nuw nsw i64 %{{.+}}, 13
18     // CHECK-NOT: lshr
19     // CHECK-NOT: udiv
20     let r = slice_of_arrays.as_ptr_range();
21     let r = r.start.cast()..r.end.cast();
22     unsafe { core::slice::from_ptr_range(r) }
23 }