-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Add unchecked_disjoint_bitor
per ACP373
#135760
base: master
Are you sure you want to change the base?
Conversation
Some changes occurred to the intrinsics. Make sure the CTFE / Miri interpreter cc @rust-lang/miri, @rust-lang/wg-const-eval |
// For c1 to be set we need to have overflowed, but if we did then | ||
// `a` is at most `MAX-1`, which means that `c2` cannot possibly | ||
// overflow because it's adding at most `1` (since it came from `bool`) | ||
(b, unsafe { intrinsics::disjoint_bitor(c1, c2) }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The use of this intrinsic inside borrowing_sub
is missing.
@@ -167,6 +167,11 @@ pub trait BuilderMethods<'a, 'tcx>: | |||
fn unchecked_umul(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; | |||
fn and(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; | |||
fn or(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; | |||
/// Defaults to [`Self::or`], but guarantees `(lhs & rhs) == 0` so some backends | |||
/// can emit something more helpful for optimizations. | |||
fn or_disjoint(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this a method and not just a normal intrinsic? Why does this have 2 default implementations? (fallback in core
and default impl here)
Following the names from libs-api in rust-lang/libs-team#373 (comment)
Includes a fallback implementation so this doesn't have to update cg_clif or cg_gcc, and overrides it in cg_llvm to use
or disjoint
, which is available in LLVM 18 so hopefully we don't need any version checks.