From 2863da257b6a9cd026c14a0b83c0f622e34650da Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Fri, 28 Nov 2008 08:34:30 -0600 Subject: [PATCH] fixnum-shift didn't work with very large negative shift counts; BRANCHLESS_MAX macro was wrong --- vm/math.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vm/math.c b/vm/math.c index 7e2274f30f..dd01e852ad 100644 --- a/vm/math.c +++ b/vm/math.c @@ -86,8 +86,8 @@ void primitive_fixnum_divmod(void) * If we're shifting right by n bits, we won't overflow as long as none of the * high WORD_SIZE-TAG_BITS-n bits are set. */ -#define SIGN_MASK(x) ((x) >> (CELLS * 8 - 1)) -#define BRANCHLESS_MAX(x,y) (x - ((x - y) & SIGN_MASK(x - y))) +#define SIGN_MASK(x) ((x) >> (WORD_SIZE - 1)) +#define BRANCHLESS_MAX(x,y) ((x) - (((x) - (y)) & SIGN_MASK((x) - (y)))) #define BRANCHLESS_ABS(x) ((x ^ SIGN_MASK(x)) - SIGN_MASK(x)) void primitive_fixnum_shift(void)