-
Notifications
You must be signed in to change notification settings - Fork 294
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Why the identity function can be used as unlikely function? #482
Comments
The compiler can't distinguish them. Without the But with the nightly feature... #[cfg(feature = "nightly")]
use core::intrinsics::{likely, unlikely}; the actual intrinsics are used, which are still nightly only: https://doc.rust-lang.org/stable/core/intrinsics/fn.likely.html |
Ok. I am looking for the implementation of the So in the current stable rust, the old implementation does not work and we can not achieve it now? @exrok |
Correct that is the my current understanding. I am not aware of a stable implementation of the likely and unlikely. You could try the olds impls from hashbrown (removed here d677fd4) the logic behind seems sounds it is just a question of if they help LLVM consistently. Sometimes even the unstable intrinsics don't help consistently: rust-lang/rust#88767 Also note, the current likely/unlikely intrinsics are currently marked "perma-unstable", so don't expect them to stabilize soon: rust-lang/rust#26179 (comment) In terms of stable solutions I think the closest would be PGO: https://doc.rust-lang.org/rustc/profile-guided-optimization.html |
The reasoning seems to be that they do not help LLVM consistently: rust-lang/hashbrown#482
…LVM consistently (#1) * Add notice that the functions have been removed from `hasbrown` The reasoning seems to be that they do not help LLVM consistently: rust-lang/hashbrown#482 * Update CHANGELOG.md * Update Cargo.toml
According to the code, both
likely
andunlikely
functions use theidentity
function. Why this function can be used asunlikely
? How it works? How the compiler distinguishlikely
fromunlikely
?Thanks in advance
The text was updated successfully, but these errors were encountered: