fix multiply of -2^30 to itself on 64-bit platforms

original commit: 566c7a98ec4e070a26450781ffc2b9054860e4ed
This commit is contained in:
Bob Burger 2019-05-02 15:19:58 -04:00
parent 897e53b430
commit 62907754b4
4 changed files with 38 additions and 3 deletions

2
LOG
View File

@ -1359,3 +1359,5 @@
- added MinGW/MSYS build support for Windows and configuration for
Travis-CI testing of all Windows builds
BUILDING, .travis*, wininstall/Makefile
- fix multiply of -2^30 to itself on 64-bit platforms
number.c, 5_3.ms, release_notes.stex

View File

@ -637,9 +637,13 @@ static ptr big_mul(tc, x, y, xl, yl, sign) ptr tc, x, y; iptr xl, yl; IBOOL sign
return copy_normalize(&BIGIT(W(tc),0),xl+yl,sign);
}
#define SHORTMIN (most_negative_fixnum / (1 << (fixnum_bits / 2)))
#define SHORTMAX (most_positive_fixnum / (1 << (fixnum_bits / 2)))
#define SHORTRANGE(x) ((x) >= SHORTMIN && (x) <= SHORTMAX)
/* SHORTRANGE is -floor(sqrt(most_positive_fixnum))..floor(sqrt(most_positive_fixnum)).
We don't use sqrt because it rounds up for fixnum_bits = 61 */
#if (fixnum_bits == 30)
#define SHORTRANGE(x) (-23170 <= (x) && (x) <= 23170)
#elif (fixnum_bits == 61)
#define SHORTRANGE(x) (-0x3FFFFFFF <= (x) && (x) <= 0x3FFFFFFF)
#endif
ptr S_mul(x, y) ptr x, y; {
ptr tc = get_thread_context();

View File

@ -1599,6 +1599,30 @@
(error? (* 'a 3 4))
(error? (* 3 5 'a 4))
(eqv? (* 1 2) 2)
(eqv? (* 23170 23170) 536848900)
(eqv? (* 23170 -23170) -536848900)
(eqv? (* -23170 23170) -536848900)
(eqv? (* -23170 -23170) 536848900)
(eqv? (* 23171 23170) 536872070)
(eqv? (* 23171 -23170) -536872070)
(eqv? (* -23171 23170) -536872070)
(eqv? (* -23171 -23170) 536872070)
(eqv? (* 23171 23171) 536895241)
(eqv? (* 23171 -23171) -536895241)
(eqv? (* -23171 23171) -536895241)
(eqv? (* -23171 -23171) 536895241)
(eqv? (* #x3FFFFFFF #x3FFFFFFF) #xFFFFFFF80000001)
(eqv? (* #x3FFFFFFF #x-3FFFFFFF) #x-FFFFFFF80000001)
(eqv? (* #x-3FFFFFFF #x3FFFFFFF) #x-FFFFFFF80000001)
(eqv? (* #x-3FFFFFFF #x-3FFFFFFF) #xFFFFFFF80000001)
(eqv? (* #x40000000 #x3FFFFFFF) #xFFFFFFFC0000000)
(eqv? (* #x40000000 #x-3FFFFFFF) #x-FFFFFFFC0000000)
(eqv? (* #x-40000000 #x3FFFFFFF) #x-FFFFFFFC0000000)
(eqv? (* #x-40000000 #x-3FFFFFFF) #xFFFFFFFC0000000)
(eqv? (* #x40000000 #x40000000) #x1000000000000000)
(eqv? (* #x40000000 #x-40000000) #x-1000000000000000)
(eqv? (* #x-40000000 #x40000000) #x-1000000000000000)
(eqv? (* #x-40000000 #x-40000000) #x1000000000000000)
(fl~= (* 1.0 2) 2.0)
(fl~= (* 1 2.0) 2.0)
(eqv? (* 3/5 2/5) 6/25)

View File

@ -1695,6 +1695,11 @@ in fasl files does not generally make sense.
%-----------------------------------------------------------------------------
\section{Bug Fixes}\label{section:bugfixes}
\subsection{Muliplication of $-2^{30}$ by itself on 64-bit platforms (9.5.3)}
A bug that produced the wrong sign when multiplying $-2^{30}$ by
itself on 64-bit platforms has been fixed.
\subsection{Compiler dropping affects from record-accessor calls (9.5.3)}
A bug that could cause the source optimizer to drop effects within