about summary refs log tree commit diff
path: root/tests/codegen-llvm/issues/matches-logical-or-141497.rs
blob: 348f62096a5f267d3a3ba03fa97c16bb6bc1d99d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// Tests that `matches!` optimizes the same as
// `f == FrameType::Inter || f == FrameType::Switch`.

//@ compile-flags: -Copt-level=3
//@ min-llvm-version: 21

#![crate_type = "lib"]

#[derive(Clone, Copy, PartialEq, Eq)]
pub enum FrameType {
    Key = 0,
    Inter = 1,
    Intra = 2,
    Switch = 3,
}

// CHECK-LABEL: @is_inter_or_switch
#[no_mangle]
pub fn is_inter_or_switch(f: FrameType) -> bool {
    // CHECK-NEXT: start:
    // CHECK-NEXT: and i8
    // CHECK-NEXT: icmp
    // CHECK-NEXT: ret
    matches!(f, FrameType::Inter | FrameType::Switch)
}