Skip to content

Commit 9ef7e4a

Browse files
authored
Unrolled build for rust-lang#131920
Rollup merge of rust-lang#131920 - clubby789:108395-test, r=jieyouxu Add codegen test for branchy bool match Closes rust-lang#108395
2 parents da93539 + aa299a9 commit 9ef7e4a

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//@ compile-flags: -O -Zmerge-functions=disabled
2+
//! Test for <https://github.com/rust-lang/rust/issues/108395>. Check that
3+
//! matching on two bools with wildcards does not produce branches.
4+
#![crate_type = "lib"]
5+
6+
// CHECK-LABEL: @wildcard(
7+
#[no_mangle]
8+
pub fn wildcard(a: u16, b: u16, v: u16) -> u16 {
9+
// CHECK-NOT: br
10+
match (a == v, b == v) {
11+
(true, false) => 0,
12+
(false, true) => u16::MAX,
13+
_ => 1 << 15, // half
14+
}
15+
}
16+
17+
// CHECK-LABEL: @exhaustive(
18+
#[no_mangle]
19+
pub fn exhaustive(a: u16, b: u16, v: u16) -> u16 {
20+
// CHECK-NOT: br
21+
match (a == v, b == v) {
22+
(true, false) => 0,
23+
(false, true) => u16::MAX,
24+
(true, true) => 1 << 15,
25+
(false, false) => 1 << 15,
26+
}
27+
}

0 commit comments

Comments
 (0)