Closed
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
Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.Category: An issue proposing an enhancement or a PR with one.Issue: Problems and improvements with respect to performance of generated code.Relevant to the compiler team, which will review and decide on the PR/issue.