mirror of
https://github.com/rust-lang/rust.git
synced 2025-12-01 12:08:30 +00:00
LLVM 22 is able to drop assumes that seem to not help further optimizations, which actually seems to dramatically _help_ further optimizations in some of our small test cases.
71 lines
1.5 KiB
Rust
71 lines
1.5 KiB
Rust
//@ compile-flags: -Copt-level=3
|
|
//@ revisions: new old
|
|
//@ [old] ignore-llvm-version: 22 - 99
|
|
//@ [new] min-llvm-version: 22
|
|
|
|
#![crate_type = "lib"]
|
|
|
|
use std::collections::VecDeque;
|
|
|
|
#[no_mangle]
|
|
// CHECK-LABEL: @noop_back(
|
|
pub fn noop_back(v: &mut VecDeque<u8>) {
|
|
// CHECK-NOT: grow
|
|
// old: tail call void @llvm.assume
|
|
// CHECK-NOT: grow
|
|
// CHECK: ret
|
|
if let Some(x) = v.pop_back() {
|
|
v.push_back(x);
|
|
}
|
|
}
|
|
|
|
#[no_mangle]
|
|
// CHECK-LABEL: @noop_front(
|
|
pub fn noop_front(v: &mut VecDeque<u8>) {
|
|
// CHECK-NOT: grow
|
|
// CHECK: tail call void @llvm.assume
|
|
// CHECK-NOT: grow
|
|
// CHECK: ret
|
|
if let Some(x) = v.pop_front() {
|
|
v.push_front(x);
|
|
}
|
|
}
|
|
|
|
#[no_mangle]
|
|
// CHECK-LABEL: @move_byte_front_to_back(
|
|
pub fn move_byte_front_to_back(v: &mut VecDeque<u8>) {
|
|
// CHECK-NOT: grow
|
|
// CHECK: tail call void @llvm.assume
|
|
// CHECK-NOT: grow
|
|
// CHECK: ret
|
|
if let Some(x) = v.pop_front() {
|
|
v.push_back(x);
|
|
}
|
|
}
|
|
|
|
#[no_mangle]
|
|
// CHECK-LABEL: @move_byte_back_to_front(
|
|
pub fn move_byte_back_to_front(v: &mut VecDeque<u8>) {
|
|
// CHECK-NOT: grow
|
|
// CHECK: tail call void @llvm.assume
|
|
// CHECK-NOT: grow
|
|
// CHECK: ret
|
|
if let Some(x) = v.pop_back() {
|
|
v.push_front(x);
|
|
}
|
|
}
|
|
|
|
#[no_mangle]
|
|
// CHECK-LABEL: @push_back_byte(
|
|
pub fn push_back_byte(v: &mut VecDeque<u8>) {
|
|
// CHECK: call {{.*}}grow
|
|
v.push_back(3);
|
|
}
|
|
|
|
#[no_mangle]
|
|
// CHECK-LABEL: @push_front_byte(
|
|
pub fn push_front_byte(v: &mut VecDeque<u8>) {
|
|
// CHECK: call {{.*}}grow
|
|
v.push_front(3);
|
|
}
|