After http://github.com/llvm/llvm-project/pull/178977, the and + icmp are folded to trunc.
24 lines
552 B
Rust
24 lines
552 B
Rust
// Tests that `matches!` optimizes the same as
|
|
// `f == FrameType::Inter || f == FrameType::Switch`.
|
|
|
|
//@ compile-flags: -Copt-level=3
|
|
//@ min-llvm-version: 23
|
|
|
|
#![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: trunc i8 %{{.*}} to i1
|
|
// CHECK-NEXT: ret
|
|
matches!(f, FrameType::Inter | FrameType::Switch)
|
|
}
|