diff options
author | Marco Bodrato <bodrato@mail.dm.unipi.it> | 2019-11-17 18:34:30 +0100 |
---|---|---|
committer | Marco Bodrato <bodrato@mail.dm.unipi.it> | 2019-11-17 18:34:30 +0100 |
commit | eebf697b08b58bf4ff4eb660bf518c71ee102539 (patch) | |
tree | 334d7e699f4542d6433113e8041394bef8265611 /mpn/sparc64 | |
parent | 9d5f47358e903e79284362b68926cc7bca478e41 (diff) | |
download | gmp-eebf697b08b58bf4ff4eb660bf518c71ee102539.tar.gz |
mpn/sparc64/dive_1.c: Avoid undefined behavior: << 64.
Diffstat (limited to 'mpn/sparc64')
-rw-r--r-- | mpn/sparc64/dive_1.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/mpn/sparc64/dive_1.c b/mpn/sparc64/dive_1.c index 323877c99..4264f292d 100644 --- a/mpn/sparc64/dive_1.c +++ b/mpn/sparc64/dive_1.c @@ -4,7 +4,7 @@ CERTAIN TO BE SUBJECT TO INCOMPATIBLE CHANGES OR DISAPPEAR COMPLETELY IN FUTURE GNU MP RELEASES. -Copyright 2000, 2001, 2003 Free Software Foundation, Inc. +Copyright 2000, 2001, 2003, 2019 Free Software Foundation, Inc. This file is part of the GNU MP Library. @@ -87,16 +87,20 @@ mpn_divexact_1 (mp_ptr dst, mp_srcptr src, mp_size_t size, mp_limb_t divisor) { count_trailing_zeros (rshift, divisor); divisor >>= rshift; + lshift = 64 - rshift; + + lshift_mask = MP_LIMB_T_MAX; } else - rshift = 0; - - binvert_limb (inverse, divisor); + { + rshift = 0; - lshift = 64 - rshift; + /* rshift==0 means no shift, so must mask out other part in this case */ + lshift = 0; + lshift_mask = 0; + } - /* lshift==64 means no shift, so must mask out other part in this case */ - lshift_mask = (rshift == 0 ? 0 : MP_LIMB_T_MAX); + binvert_limb (inverse, divisor); c = 0; divisor_h = HIGH32 (divisor); |