diff options
| author | DianQK <dianqk@dianqk.net> | 2024-02-21 20:53:27 +0800 |
|---|---|---|
| committer | DianQK <dianqk@dianqk.net> | 2024-04-08 19:20:04 +0800 |
| commit | 928c57dc9ad4caf66770235aab1a6850acebd649 (patch) | |
| tree | f8c8d529c0fc942667e7e3cf8f523193ef7f57f2 /tests/codegen/enum | |
| parent | a334848ba32938c7ba8c3a65595d1a10d88d354e (diff) | |
| download | rust-928c57dc9ad4caf66770235aab1a6850acebd649.tar.gz rust-928c57dc9ad4caf66770235aab1a6850acebd649.zip | |
Add test case for #119014
Diffstat (limited to 'tests/codegen/enum')
| -rw-r--r-- | tests/codegen/enum/enum-early-otherwise-branch.rs | 26 |
1 files changed, 26 insertions, 0 deletions
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 00000000000..6c7548912da --- /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, + } +} |
