Patch to fix lshift_double and rshift_double
John Wehle
john@feith.com
Thu Dec 30 20:21:00 GMT 1999
These routines attempt to shift by HOST_BITS_PER_WIDE_INT when
called with count equal to 2 * HOST_BITS_PER_WIDE_INT. This
produces unexpected results since shifting by the host word size
is undefined according to ANSI.
ChangeLog:
Thu Dec 30 03:34:10 EST 1999 John Wehle (john@feith.com)
* fold-const.c (lshift_double, rshift_double): Handle
shifting by 2 * HOST_BITS_PER_WIDE_INT correctly.
Enjoy!
-- John Wehle
------------------8<------------------------8<------------------------
*** gcc/fold-const.c.ORIGINAL Sun Oct 31 20:11:20 1999
--- gcc/fold-const.c Thu Dec 30 03:15:51 1999
*************** lshift_double (l1, h1, count, prec, lv,
*** 360,366 ****
count %= prec;
#endif
! if (count >= HOST_BITS_PER_WIDE_INT)
{
*hv = (unsigned HOST_WIDE_INT) l1 << (count - HOST_BITS_PER_WIDE_INT);
*lv = 0;
--- 360,373 ----
count %= prec;
#endif
! 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;
*************** rshift_double (l1, h1, count, prec, lv,
*** 395,401 ****
count %= prec;
#endif
! if (count >= HOST_BITS_PER_WIDE_INT)
{
*hv = signmask;
*lv = ((signmask << (2 * HOST_BITS_PER_WIDE_INT - count - 1) << 1)
--- 402,415 ----
count %= prec;
#endif
! 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)
-------------------------------------------------------------------------
| Feith Systems | Voice: 1-215-646-8000 | Email: john@feith.com |
| John Wehle | Fax: 1-215-540-5495 | |
-------------------------------------------------------------------------
More information about the Gcc-patches
mailing list