From 928c57dc9ad4caf66770235aab1a6850acebd649 Mon Sep 17 00:00:00 2001 From: DianQK Date: Wed, 21 Feb 2024 20:53:27 +0800 Subject: [PATCH] Add test case for #119014 --- .../enum/enum-early-otherwise-branch.rs | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 tests/codegen/enum/enum-early-otherwise-branch.rs diff --git a/tests/codegen/enum/enum-early-otherwise-branch.rs b/tests/codegen/enum/enum-early-otherwise-branch.rs new file mode 100644 index 0000000000000..6c7548912dacb --- /dev/null +++ b/tests/codegen/enum/enum-early-otherwise-branch.rs @@ -0,0 +1,26 @@ +//@ compile-flags: -O +//@ min-llvm-version: 18 + +#![crate_type = "lib"] + +pub enum Enum { + A(u32), + B(u32), + C(u32), +} + +#[no_mangle] +pub fn foo(lhs: &Enum, rhs: &Enum) -> bool { + // CHECK-LABEL: define{{.*}}i1 @foo( + // CHECK-NOT: switch + // CHECK-NOT: br + // CHECK: [[SELECT:%.*]] = select + // CHECK-NEXT: ret i1 [[SELECT]] + // CHECK-NEXT: } + match (lhs, rhs) { + (Enum::A(lhs), Enum::A(rhs)) => lhs == rhs, + (Enum::B(lhs), Enum::B(rhs)) => lhs == rhs, + (Enum::C(lhs), Enum::C(rhs)) => lhs == rhs, + _ => false, + } +}