Tracking Issue for hint::select_unpredictable
· Issue #133962 · rust-lang/rust (original) (raw)
Feature gate: #![feature(select_unpredictable)]
This is a tracking issue for hint::select_unpredictable
, which selects between two values and hints to the optimizer that it should try to generate branchless code.
Public API
// core::hint
/// Returns either true_val
or false_val
depending on the value of
/// b
, with a hint to the compiler that condition
is unlikely
/// to be correctly predicted by a CPU’s branch predictor.
pub fn select_unpredictable(b: bool, true_val: T, false_val: T) -> T;
Steps / History
- ACP: ACP: add bool::select libs-team#468
- Implementation: core: implement bool::select_unpredictable #133964
- Moved to
core::hint
: Move select_unpredictable to the hint module #139726 - Fixed drop handling: Fix drop handling in hint::select_unpredictable #139977
- Final comment period (FCP)1
- Stabilization PR
Unresolved Questions
- This should be
const
, right?