Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 56a352f

Browse files
committed
Auto merge of #145411 - the8472:cows-have-no-branches, r=Mark-Simulacrum
regression test for Cow<[u8]> layout requested by ralf in #117763 (comment)
2 parents 9f32ccf + 5f0a68e commit 56a352f

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//@ compile-flags: -Copt-level=3
2+
//@ needs-deterministic-layouts
3+
4+
// Currently Vec<T> and &[T] have layouts that start with (pointer, len)
5+
// which makes the conversion branchless.
6+
// A nice-to-have property, not guaranteed.
7+
#![crate_type = "cdylib"]
8+
9+
// CHECK-LABEL: @branchless_cow_slices
10+
#[no_mangle]
11+
pub fn branchless_cow_slices<'a>(cow: &'a std::borrow::Cow<'a, [u8]>) -> &'a [u8] {
12+
// CHECK-NOT: br
13+
// CHECK-NOT: select
14+
// CHECK-NOT: icmp
15+
// CHECK: ret { ptr, {{i32|i64}} }
16+
&*cow
17+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /