Suboptimal codegen when using unwrap_or_else with unreachable_unchecked #98468
Labels
A-LLVM
Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.
C-bug
Category: This is a bug.
I-slow
Issue: Problems and improvements with respect to performance of generated code.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
I tried this code:
I expected to see this happen: The
unwrap_or_else
case generates branch-free assembly.Instead, this happened:
This was the generated assembly (opt-level 3):
Meta
Rust version rustc 1.61.0 (fe5b13d 2022-05-18) (on Compiler Explorer)
rustc --version --verbose
:(not at my home machine right now, will fill in these details soon)
Context
The primary use case is to have an alternative version of
std::hint::unreachable_unchecked
that is checked in debug builds viaunreachable!()
, but unchecked in release builds.The text was updated successfully, but these errors were encountered: