diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c5c131fb86f..ade9b9d28c3 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +Sun Jan 9 01:02:55 EST 2000 John Wehle (john@feith.com) + + * fold-const.c (lshift_double, rshift_double): Handle + shifting by 2 * HOST_BITS_PER_WIDE_INT correctly. + 2000-01-08 Alexandre Oliva * toplev.c (rest_of_compilation): Initialize cse_not_expected as diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 976cf3aad30..64d4e41ff46 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -363,7 +363,14 @@ lshift_double (l1, h1, count, prec, lv, hv, arith) count %= prec; #endif - if (count >= HOST_BITS_PER_WIDE_INT) + if (count >= 2 * HOST_BITS_PER_WIDE_INT) + { + /* Shifting by the host word size is undefined according to the + ANSI standard, so we must handle this as a special case. */ + *hv = 0; + *lv = 0; + } + else if (count >= HOST_BITS_PER_WIDE_INT) { *hv = (unsigned HOST_WIDE_INT) l1 << (count - HOST_BITS_PER_WIDE_INT); *lv = 0; @@ -398,7 +405,14 @@ rshift_double (l1, h1, count, prec, lv, hv, arith) count %= prec; #endif - if (count >= HOST_BITS_PER_WIDE_INT) + if (count >= 2 * HOST_BITS_PER_WIDE_INT) + { + /* Shifting by the host word size is undefined according to the + ANSI standard, so we must handle this as a special case. */ + *hv = signmask; + *lv = signmask; + } + else if (count >= HOST_BITS_PER_WIDE_INT) { *hv = signmask; *lv = ((signmask << (2 * HOST_BITS_PER_WIDE_INT - count - 1) << 1)