regression test for https://github.com/rust-lang/rust/issues/117763
This commit is contained in:
parent
6710835ae7
commit
5f0a68eb22
1 changed files with 17 additions and 0 deletions
17
tests/codegen-llvm/issues/cows-dont-have-branches-117763.rs
Normal file
17
tests/codegen-llvm/issues/cows-dont-have-branches-117763.rs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
//@ compile-flags: -Copt-level=3
|
||||
//@ needs-deterministic-layouts
|
||||
|
||||
// Currently Vec<T> and &[T] have layouts that start with (pointer, len)
|
||||
// which makes the conversion branchless.
|
||||
// A nice-to-have property, not guaranteed.
|
||||
#![crate_type = "cdylib"]
|
||||
|
||||
// CHECK-LABEL: @branchless_cow_slices
|
||||
#[no_mangle]
|
||||
pub fn branchless_cow_slices<'a>(cow: &'a std::borrow::Cow<'a, [u8]>) -> &'a [u8] {
|
||||
// CHECK-NOT: br
|
||||
// CHECK-NOT: select
|
||||
// CHECK-NOT: icmp
|
||||
// CHECK: ret { ptr, {{i32|i64}} }
|
||||
&*cow
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue