1 /* mpn_mul_1 -- Multiply a limb vector with a single limb and store the
2 product in a second limb vector.
4 Copyright 1991, 1992, 1993, 1994, 1996, 2000, 2001, 2002 Free Software
7 This file is part of the GNU MP Library.
9 The GNU MP Library is free software; you can redistribute it and/or modify
10 it under the terms of the GNU Lesser General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or (at your
12 option) any later version.
14 The GNU MP Library is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
17 License for more details.
19 You should have received a copy of the GNU Lesser General Public License
20 along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */
27 #if GMP_NAIL_BITS == 0
30 mpn_mul_1 (mp_ptr rp, mp_srcptr up, mp_size_t n, mp_limb_t vl)
32 mp_limb_t ul, cl, hpl, lpl;
35 ASSERT (MPN_SAME_OR_INCR_P (rp, up, n));
41 umul_ppmm (hpl, lpl, ul, vl);
44 cl = (lpl < cl) + hpl;
55 #if GMP_NAIL_BITS >= 1
58 mpn_mul_1 (mp_ptr rp, mp_srcptr up, mp_size_t n, mp_limb_t vl)
60 mp_limb_t shifted_vl, ul, lpl, hpl, prev_hpl, xw, cl, xl;
63 ASSERT (MPN_SAME_OR_INCR_P (rp, up, n));
67 shifted_vl = vl << GMP_NAIL_BITS;
74 umul_ppmm (hpl, lpl, ul, shifted_vl);
75 lpl >>= GMP_NAIL_BITS;
76 xw = prev_hpl + lpl + cl;
77 cl = xw >> GMP_NUMB_BITS;
78 xl = xw & GMP_NUMB_MASK;