Rollup merge of #89351 - tspiteri:wrapping_rem, r=dtolnay
for signed wrapping remainder, do not compare lhs with MIN Since the wrapped remainder is going to be 0 for all cases when the rhs is -1, there is no need to compare the lhs with MIN.
This commit is contained in:
commit
e745e098c4
@ -1533,9 +1533,8 @@ pub const fn overflowing_div_euclid(self, rhs: Self) -> (Self, bool) {
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
pub const fn overflowing_rem(self, rhs: Self) -> (Self, bool) {
|
||||
// Using `&` helps LLVM see that it is the same check made in division.
|
||||
if unlikely!((self == Self::MIN) & (rhs == -1)) {
|
||||
(0, true)
|
||||
if unlikely!(rhs == -1) {
|
||||
(0, self == Self::MIN)
|
||||
} else {
|
||||
(self % rhs, false)
|
||||
}
|
||||
@ -1565,9 +1564,8 @@ pub const fn overflowing_rem(self, rhs: Self) -> (Self, bool) {
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
pub const fn overflowing_rem_euclid(self, rhs: Self) -> (Self, bool) {
|
||||
// Using `&` helps LLVM see that it is the same check made in division.
|
||||
if unlikely!((self == Self::MIN) & (rhs == -1)) {
|
||||
(0, true)
|
||||
if unlikely!(rhs == -1) {
|
||||
(0, self == Self::MIN)
|
||||
} else {
|
||||
(self.rem_euclid(rhs), false)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user