-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.I-slowIssue: Problems and improvements with respect to performance of generated code.Issue: Problems and improvements with respect to performance of generated code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
The following:
pub enum All {
None,
Foo,
Bar,
}
pub fn f(a: &mut All, q: i32) -> i32 {
*a = if (q == 5) {
All::Foo
} else {
All::Bar
};
match *a {
All::None => unreachable!(),
All::Foo => 1,
All::Bar => 2,
}
}
compiles to:
example::f:
cmp esi, 5
sete al
mov cl, 2
sub cl, al
mov byte ptr [rdi], cl
mov eax, 1
cmp cl, 1
je .LBB6_3
cmp cl, 2
jne .LBB6_4
mov eax, 2
.LBB6_3:
ret
.LBB6_4:
push rax
call std::panicking::begin_panic
ud2
The unreachable!
and should be eliminated
Metadata
Metadata
Assignees
Labels
A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.I-slowIssue: Problems and improvements with respect to performance of generated code.Issue: Problems and improvements with respect to performance of generated code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.