20 lines
457 B
Rust
20 lines
457 B
Rust
|
// in Rust 1.73, -O and opt-level=3 optimizes differently
|
||
|
//@ compile-flags: -C opt-level=3
|
||
|
//@ min-llvm-version: 17
|
||
|
#![crate_type = "lib"]
|
||
|
|
||
|
use std::cmp::max;
|
||
|
|
||
|
#[no_mangle]
|
||
|
// CHECK-LABEL: @foo
|
||
|
// CHECK-NOT: slice_start_index_len_fail
|
||
|
// CHECK-NOT: unreachable
|
||
|
pub fn foo(v: &mut Vec<u8>, size: usize)-> Option<&mut [u8]> {
|
||
|
if v.len() > max(1, size) {
|
||
|
let start = v.len() - size;
|
||
|
Some(&mut v[start..])
|
||
|
} else {
|
||
|
None
|
||
|
}
|
||
|
}
|