From 4c8341f7a6786484be1feb7e668827a6f507ae77 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 | 25 +++++++++++++++++++ 1 file changed, 25 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..07c8aed2624c1 --- /dev/null +++ b/tests/codegen/enum/enum-early-otherwise-branch.rs @@ -0,0 +1,25 @@ +//@ compile-flags: -O + +#![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, + } +}