11//! Reciprocal, shared across Uint and BoxedUint
2- use crate :: { ConstChoice , Limb , NonZero , Word , primitives } ;
2+ use crate :: { primitives , ConstChoice , Limb , NonZero , Word } ;
33use subtle:: { Choice , ConditionallySelectable } ;
44
55/// Calculates the reciprocal of the given 32-bit divisor with the highmost bit set.
@@ -12,14 +12,14 @@ pub const fn reciprocal(d: Word) -> Word {
1212 let d21 = ( d >> 11 ) + 1 ;
1313 let d31 = ( d >> 1 ) + d0;
1414 let v0 = short_div ( ( 1 << 24 ) - ( 1 << 14 ) + ( 1 << 9 ) , 24 , d10, 10 ) ;
15- let ( hi, _lo) = mulhilo ( v0 * v0, d21) ;
15+ let ( hi, _lo) = primitives :: mulhilo ( v0 * v0, d21) ;
1616 let v1 = ( v0 << 4 ) - hi - 1 ;
1717
1818 // Checks that the expression for `e` can be simplified in the way we did below.
19- debug_assert ! ( mulhilo( v1, d31) . 0 == ( 1 << 16 ) - 1 ) ;
19+ debug_assert ! ( primitives :: mulhilo( v1, d31) . 0 == ( 1 << 16 ) - 1 ) ;
2020 let e = Word :: MAX - v1. wrapping_mul ( d31) + 1 + ( v1 >> 1 ) * d0;
2121
22- let ( hi, _lo) = mulhilo ( v1, e) ;
22+ let ( hi, _lo) = primitives :: mulhilo ( v1, e) ;
2323 // Note: the paper does not mention a wrapping add here,
2424 // but the 64-bit version has it at this stage, and the function panics without it
2525 // when calculating a reciprocal for `Word::MAX`.
@@ -29,7 +29,7 @@ pub const fn reciprocal(d: Word) -> Word {
2929 // If `v2 == 2^32-1` this should give `d`, but we can't achieve this in our wrapping arithmetic.
3030 // Hence the `ct_select()`.
3131 let x = v2. wrapping_add ( 1 ) ;
32- let ( hi, _lo) = mulhilo ( x, d) ;
32+ let ( hi, _lo) = primitives :: mulhilo ( x, d) ;
3333 let hi = ConstChoice :: from_u32_nonzero ( x) . select_word ( d, hi) ;
3434
3535 v2. wrapping_sub ( hi) . wrapping_sub ( d)
0 commit comments