diff options
author | Richard Stallman <rms@gnu.org> | 1992-09-19 19:00:40 +0000 |
---|---|---|
committer | Richard Stallman <rms@gnu.org> | 1992-09-19 19:00:40 +0000 |
commit | b6b19f41c6f312715ed7d64f5ce1e9b22ca5092b (patch) | |
tree | d988222c4e4f17a3c98fc9124d10b1c0f9143564 /gcc | |
parent | 91f9a6ede477e36a56e9c287acf464b7541d380b (diff) | |
download | gcc-b6b19f41c6f312715ed7d64f5ce1e9b22ca5092b.zip gcc-b6b19f41c6f312715ed7d64f5ce1e9b22ca5092b.tar.gz gcc-b6b19f41c6f312715ed7d64f5ce1e9b22ca5092b.tar.bz2 |
(fold_convert): Avoid using conversion of unsigned
to floating; offset value by hand to fit in signed type.
From-SVN: r2165
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/fold-const.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 126aac4..f2aa59f 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -1517,7 +1517,13 @@ fold_convert (t, arg1) high = (HOST_WIDE_INT) (d / half_word / half_word); d -= (REAL_VALUE_TYPE) high * half_word * half_word; - low = (unsigned HOST_WIDE_INT) d; + if (d >= (REAL_VALUE_TYPE) half_word * half_word / 2) + { + low = d - (REAL_VALUE_TYPE) half_word * half_word / 2; + low |= 1 << (HOST_BITS_PER_WIDE_INT - 1); + } + else + low = (HOST_WIDE_INT) d; if (TREE_REAL_CST (arg1) < 0) neg_double (low, high, &low, &high); t = build_int_2 (low, high); |