From eebf697b08b58bf4ff4eb660bf518c71ee102539 Mon Sep 17 00:00:00 2001 From: Marco Bodrato Date: Sun, 17 Nov 2019 18:34:30 +0100 Subject: mpn/sparc64/dive_1.c: Avoid undefined behavior: << 64. --- mpn/sparc64/dive_1.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'mpn/sparc64') 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); -- cgit v1.2.1