]>
git.proxmox.com Git - rustc.git/blob - src/test/codegen/issue-69101-bounds-check.rs
3 // ignore-debug: the debug assertions get in the way
6 // Make sure no bounds checks are emitted in the loop when upfront slicing
7 // ensures that the slices are big enough.
8 // In particular, bounds checks were not always optimized out if the upfront
9 // check was for a greater len than the loop requires.
10 // (i.e. `already_sliced_no_bounds_check` was not always optimized even when
11 // `already_sliced_no_bounds_check_exact` was)
12 // CHECK-LABEL: @already_sliced_no_bounds_check
14 pub fn already_sliced_no_bounds_check(a
: &[u8], b
: &[u8], c
: &mut [u8]) {
15 // CHECK: slice_index_len_fail
16 // CHECK-NOT: panic_bounds_check
17 let _
= (&a
[..2048], &b
[..2048], &mut c
[..2048]);
23 // CHECK-LABEL: @already_sliced_no_bounds_check_exact
25 pub fn already_sliced_no_bounds_check_exact(a
: &[u8], b
: &[u8], c
: &mut [u8]) {
26 // CHECK: slice_index_len_fail
27 // CHECK-NOT: panic_bounds_check
28 let _
= (&a
[..1024], &b
[..1024], &mut c
[..1024]);
34 // Make sure we're checking for the right thing: there can be a panic if the slice is too small.
35 // CHECK-LABEL: @already_sliced_bounds_check
37 pub fn already_sliced_bounds_check(a
: &[u8], b
: &[u8], c
: &mut [u8]) {
38 // CHECK: slice_index_len_fail
39 // CHECK: panic_bounds_check
40 let _
= (&a
[..1023], &b
[..2048], &mut c
[..2048]);