File tree 2 files changed +15
-4
lines changed
2 files changed +15
-4
lines changed Original file line number Diff line number Diff line change 1
- use core:: mem;
2
1
use core:: num:: Wrapping ;
3
2
4
3
use float:: Float ;
@@ -75,7 +74,10 @@ macro_rules! add {
75
74
76
75
// Swap a and b if necessary so that a has the larger absolute value.
77
76
if b_abs > a_abs {
78
- mem:: swap( & mut a_rep, & mut b_rep) ;
77
+ // Don't use mem::swap because it may generate references to memcpy in unoptimized code.
78
+ let tmp = a_rep;
79
+ a_rep = b_rep;
80
+ b_rep = tmp;
79
81
}
80
82
81
83
// Extract the exponent and significand from the (possibly swapped) a and b.
Original file line number Diff line number Diff line change @@ -125,7 +125,11 @@ macro_rules! udivmod_inner {
125
125
// 1 <= sr <= u64::bits() - 1
126
126
let mut carry = 0 ;
127
127
128
- for _ in 0 ..sr {
128
+ // Don't use a range because they may generate references to memcpy in unoptimized code
129
+ let mut i = 0 ;
130
+ while i < sr {
131
+ i += 1 ;
132
+
129
133
// r:q = ((r:q) << 1) | carry
130
134
r = ( r << 1 ) | ( q >> ( <$ty>:: bits( ) - 1 ) ) ;
131
135
q = ( q << 1 ) | carry as $ty;
@@ -181,7 +185,12 @@ intrinsics! {
181
185
let mut r = n >> sr;
182
186
183
187
let mut carry = 0 ;
184
- for _ in 0 ..sr {
188
+
189
+ // Don't use a range because they may generate references to memcpy in unoptimized code
190
+ let mut i = 0 ;
191
+ while i < sr {
192
+ i += 1 ;
193
+
185
194
// r:q = ((r:q) << 1) | carry
186
195
r = ( r << 1 ) | ( q >> ( u32 :: bits( ) - 1 ) ) ;
187
196
q = ( q << 1 ) | carry;
You can’t perform that action at this time.
0 commit comments