Skip to content

Commit fcc26c3

Browse files
committed
Use BinOp::Cmp for iNN::signum
This way it can use the nice new LLVM intrinsic in LLVM20.
1 parent a18bd8a commit fcc26c3

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

library/core/src/intrinsics/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -3242,6 +3242,8 @@ pub const fn bitreverse<T: Copy>(_x: T) -> T {
32423242
/// large and difficult to optimize.
32433243
///
32443244
/// The stabilized version of this intrinsic is [`Ord::cmp`].
3245+
#[rustc_intrinsic_const_stable_indirect]
3246+
#[rustc_nounwind]
32453247
#[rustc_intrinsic]
32463248
#[rustc_intrinsic_must_be_overridden]
32473249
pub const fn three_way_compare<T: Copy>(_lhs: T, _rhss: T) -> crate::cmp::Ordering {

library/core/src/num/int_macros.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -3526,9 +3526,7 @@ macro_rules! int_impl {
35263526
// exactly like we need and can be the place to deal with the complexity.
35273527

35283528
// FIXME(const-hack): replace with cmp
3529-
if self < 0 { -1 }
3530-
else if self == 0 { 0 }
3531-
else { 1 }
3529+
crate::intrinsics::three_way_compare(self, 0) as Self
35323530
}
35333531

35343532
/// Returns `true` if `self` is positive and `false` if the number is zero or

0 commit comments

Comments
 (0)