diff options
author | wehle <wehle@138bc75d-0d04-0410-961f-82ee72b054a4> | 2000-01-09 06:03:45 +0000 |
---|---|---|
committer | wehle <wehle@138bc75d-0d04-0410-961f-82ee72b054a4> | 2000-01-09 06:03:45 +0000 |
commit | 016d117a261e488846141e31c9f308fc0302d998 (patch) | |
tree | 929408d70ce3a7b84c9acd4f8f43cf1758d6a7b5 /gcc/fold-const.c | |
parent | 451bba558ac160a79b33779575e88d462164967a (diff) | |
download | gcc-016d117a261e488846141e31c9f308fc0302d998.tar.gz |
* fold-const.c (lshift_double, rshift_double): Handle
shifting by 2 * HOST_BITS_PER_WIDE_INT correctly.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@31289 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r-- | gcc/fold-const.c | 18 |
1 files changed, 16 insertions, 2 deletions
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) |