aboutsummaryrefslogtreecommitdiff
path: root/gcc/fold-const.c
diff options
context:
space:
mode:
authorJohn Wehle <john@feith.com>2000-01-09 06:03:45 +0000
committerJohn Wehle <wehle@gcc.gnu.org>2000-01-09 06:03:45 +0000
commitcb0a34c469abd6fc7e6a54fe620706ff0f2f136f (patch)
tree929408d70ce3a7b84c9acd4f8f43cf1758d6a7b5 /gcc/fold-const.c
parentd511f9d5ecc8d4f5a7a6dc1ba239ad67e0816773 (diff)
downloadgcc-cb0a34c469abd6fc7e6a54fe620706ff0f2f136f.zip
gcc-cb0a34c469abd6fc7e6a54fe620706ff0f2f136f.tar.gz
gcc-cb0a34c469abd6fc7e6a54fe620706ff0f2f136f.tar.bz2
fold-const.c (lshift_double, [...]): Handle shifting by 2 * HOST_BITS_PER_WIDE_INT correctly.
* fold-const.c (lshift_double, rshift_double): Handle shifting by 2 * HOST_BITS_PER_WIDE_INT correctly. From-SVN: r31289
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r--gcc/fold-const.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 976cf3a..64d4e41 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)