Skip to content

Commit 3a8f4fa

Browse files
committed
Extra lets bloat the IR, unfortunately :(
1 parent 9c4c647 commit 3a8f4fa

File tree

2 files changed

+14
-32
lines changed

2 files changed

+14
-32
lines changed

library/core/src/num/int_macros.rs

+7-16
Original file line numberDiff line numberDiff line change
@@ -516,8 +516,7 @@ macro_rules! int_impl {
516516
);
517517
// SAFETY: this is guaranteed to be safe by the caller.
518518
unsafe {
519-
let lhs = self;
520-
intrinsics::unchecked_add(lhs, rhs)
519+
intrinsics::unchecked_add(self, rhs)
521520
}
522521
}
523522

@@ -660,8 +659,7 @@ macro_rules! int_impl {
660659
);
661660
// SAFETY: this is guaranteed to be safe by the caller.
662661
unsafe {
663-
let lhs = self;
664-
intrinsics::unchecked_sub(lhs, rhs)
662+
intrinsics::unchecked_sub(self, rhs)
665663
}
666664
}
667665

@@ -804,8 +802,7 @@ macro_rules! int_impl {
804802
);
805803
// SAFETY: this is guaranteed to be safe by the caller.
806804
unsafe {
807-
let lhs = self;
808-
intrinsics::unchecked_mul(lhs, rhs)
805+
intrinsics::unchecked_mul(self, rhs)
809806
}
810807
}
811808

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

@@ -1362,9 +1357,7 @@ macro_rules! int_impl {
13621357
// SAFETY: this is guaranteed to be safe by the caller.
13631358
// Any legal shift amount is losslessly representable in the self type.
13641359
unsafe {
1365-
let lhs = self;
1366-
let rhs = conv_rhs_for_unchecked_shift!($SelfT, rhs);
1367-
intrinsics::unchecked_shr(lhs, rhs)
1360+
intrinsics::unchecked_shl(self, conv_rhs_for_unchecked_shift!($SelfT, rhs))
13681361
}
13691362
}
13701363

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

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

library/core/src/num/uint_macros.rs

+7-16
Original file line numberDiff line numberDiff line change
@@ -525,8 +525,7 @@ macro_rules! uint_impl {
525525

526526
// SAFETY: this is guaranteed to be safe by the caller.
527527
unsafe {
528-
let lhs = self;
529-
intrinsics::unchecked_add(lhs, rhs)
528+
intrinsics::unchecked_add(self, rhs)
530529
}
531530
}
532531

@@ -675,8 +674,7 @@ macro_rules! uint_impl {
675674
);
676675
// SAFETY: this is guaranteed to be safe by the caller.
677676
unsafe {
678-
let lhs = self;
679-
intrinsics::unchecked_sub(lhs, rhs)
677+
intrinsics::unchecked_sub(self, rhs)
680678
}
681679
}
682680

@@ -763,8 +761,7 @@ macro_rules! uint_impl {
763761
);
764762
// SAFETY: this is guaranteed to be safe by the caller.
765763
unsafe {
766-
let lhs = self;
767-
intrinsics::unchecked_mul(lhs, rhs)
764+
intrinsics::unchecked_mul(self, rhs)
768765
}
769766
}
770767

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

@@ -1417,9 +1412,7 @@ macro_rules! uint_impl {
14171412
// SAFETY: this is guaranteed to be safe by the caller.
14181413
// Any legal shift amount is losslessly representable in the self type.
14191414
unsafe {
1420-
let lhs = self;
1421-
let rhs = conv_rhs_for_unchecked_shift!($SelfT, rhs);
1422-
intrinsics::unchecked_shr(lhs, rhs)
1415+
intrinsics::unchecked_shr(self, conv_rhs_for_unchecked_shift!($SelfT, rhs))
14231416
}
14241417
}
14251418

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

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

0 commit comments

Comments
 (0)