Skip to content

Commit

Permalink
Extra lets bloat the IR, unfortunately :(
Browse files Browse the repository at this point in the history
  • Loading branch information
clarfonthey committed Feb 24, 2024
1 parent 9c4c647 commit 3a8f4fa
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 32 deletions.
23 changes: 7 additions & 16 deletions library/core/src/num/int_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -516,8 +516,7 @@ macro_rules! int_impl {
);
// SAFETY: this is guaranteed to be safe by the caller.
unsafe {
let lhs = self;
intrinsics::unchecked_add(lhs, rhs)
intrinsics::unchecked_add(self, rhs)
}
}

Expand Down Expand Up @@ -660,8 +659,7 @@ macro_rules! int_impl {
);
// SAFETY: this is guaranteed to be safe by the caller.
unsafe {
let lhs = self;
intrinsics::unchecked_sub(lhs, rhs)
intrinsics::unchecked_sub(self, rhs)
}
}

Expand Down Expand Up @@ -804,8 +802,7 @@ macro_rules! int_impl {
);
// SAFETY: this is guaranteed to be safe by the caller.
unsafe {
let lhs = self;
intrinsics::unchecked_mul(lhs, rhs)
intrinsics::unchecked_mul(self, rhs)
}
}

Expand Down Expand Up @@ -1272,9 +1269,7 @@ macro_rules! int_impl {
// SAFETY: this is guaranteed to be safe by the caller.
// Any legal shift amount is losslessly representable in the self type.
unsafe {
let lhs = self;
let rhs = conv_rhs_for_unchecked_shift!($SelfT, rhs);
intrinsics::unchecked_shl(lhs, rhs)
intrinsics::unchecked_shl(self, conv_rhs_for_unchecked_shift!($SelfT, rhs))
}
}

Expand Down Expand Up @@ -1362,9 +1357,7 @@ macro_rules! int_impl {
// SAFETY: this is guaranteed to be safe by the caller.
// Any legal shift amount is losslessly representable in the self type.
unsafe {
let lhs = self;
let rhs = conv_rhs_for_unchecked_shift!($SelfT, rhs);
intrinsics::unchecked_shr(lhs, rhs)
intrinsics::unchecked_shl(self, conv_rhs_for_unchecked_shift!($SelfT, rhs))
}
}

Expand Down Expand Up @@ -2031,8 +2024,7 @@ macro_rules! int_impl {
unsafe {
// FIXME: we can't optimize out the extra check here,
// so, we can't just call the method for now
let rhs = conv_rhs_for_unchecked_shift!($SelfT, rhs & (Self::BITS - 1));
intrinsics::unchecked_shl(self, rhs)
intrinsics::unchecked_shl(self, conv_rhs_for_unchecked_shift!($SelfT, rhs & (Self::BITS - 1)))
}
}

Expand Down Expand Up @@ -2064,8 +2056,7 @@ macro_rules! int_impl {
unsafe {
// FIXME: we can't optimize out the extra check here,
// so, we can't just call the method for now
let rhs = conv_rhs_for_unchecked_shift!($SelfT, rhs & (Self::BITS - 1));
intrinsics::unchecked_shr(self, rhs)
intrinsics::unchecked_shr(self, conv_rhs_for_unchecked_shift!($SelfT, rhs & (Self::BITS - 1)))
}
}

Expand Down
23 changes: 7 additions & 16 deletions library/core/src/num/uint_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -525,8 +525,7 @@ macro_rules! uint_impl {

// SAFETY: this is guaranteed to be safe by the caller.
unsafe {
let lhs = self;
intrinsics::unchecked_add(lhs, rhs)
intrinsics::unchecked_add(self, rhs)
}
}

Expand Down Expand Up @@ -675,8 +674,7 @@ macro_rules! uint_impl {
);
// SAFETY: this is guaranteed to be safe by the caller.
unsafe {
let lhs = self;
intrinsics::unchecked_sub(lhs, rhs)
intrinsics::unchecked_sub(self, rhs)
}
}

Expand Down Expand Up @@ -763,8 +761,7 @@ macro_rules! uint_impl {
);
// SAFETY: this is guaranteed to be safe by the caller.
unsafe {
let lhs = self;
intrinsics::unchecked_mul(lhs, rhs)
intrinsics::unchecked_mul(self, rhs)
}
}

Expand Down Expand Up @@ -1327,9 +1324,7 @@ macro_rules! uint_impl {
// SAFETY: this is guaranteed to be safe by the caller.
// Any legal shift amount is losslessly representable in the self type.
unsafe {
let lhs = self;
let rhs = conv_rhs_for_unchecked_shift!($SelfT, rhs);
intrinsics::unchecked_shl(lhs, rhs)
intrinsics::unchecked_shl(self, conv_rhs_for_unchecked_shift!($SelfT, rhs))
}
}

Expand Down Expand Up @@ -1417,9 +1412,7 @@ macro_rules! uint_impl {
// SAFETY: this is guaranteed to be safe by the caller.
// Any legal shift amount is losslessly representable in the self type.
unsafe {
let lhs = self;
let rhs = conv_rhs_for_unchecked_shift!($SelfT, rhs);
intrinsics::unchecked_shr(lhs, rhs)
intrinsics::unchecked_shr(self, conv_rhs_for_unchecked_shift!($SelfT, rhs))
}
}

Expand Down Expand Up @@ -1913,8 +1906,7 @@ macro_rules! uint_impl {
unsafe {
// FIXME: we can't optimize out the extra check here,
// so, we can't just call the method for now
let rhs = conv_rhs_for_unchecked_shift!($SelfT, rhs & (Self::BITS - 1));
intrinsics::unchecked_shl(self, rhs)
intrinsics::unchecked_shl(self, conv_rhs_for_unchecked_shift!($SelfT, rhs & (Self::BITS - 1)))
}
}

Expand Down Expand Up @@ -1949,8 +1941,7 @@ macro_rules! uint_impl {
unsafe {
// FIXME: we can't optimize out the extra check here,
// so, we can't just call the method for now
let rhs = conv_rhs_for_unchecked_shift!($SelfT, rhs & (Self::BITS - 1));
intrinsics::unchecked_shr(self, rhs)
intrinsics::unchecked_shr(self, conv_rhs_for_unchecked_shift!($SelfT, rhs & (Self::BITS - 1)))
}
}

Expand Down

0 comments on commit 3a8f4fa

Please sign in to comment.