aboutsummaryrefslogtreecommitdiff
path: root/gcc/sreal.c
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2014-11-25 16:16:27 +0100
committerMartin Liska <marxin@gcc.gnu.org>2014-11-25 15:16:27 +0000
commit8301b194d24cb01e54f36822740ed5b835358fd1 (patch)
tree6eb6e13f7c1038e576c433fecfe7eea014d66df3 /gcc/sreal.c
parent6b4b59fc6f4b555f81e70e82dd424be2e05b41fc (diff)
downloadgcc-8301b194d24cb01e54f36822740ed5b835358fd1.zip
gcc-8301b194d24cb01e54f36822740ed5b835358fd1.tar.gz
gcc-8301b194d24cb01e54f36822740ed5b835358fd1.tar.bz2
re PR bootstrap/64050 (r218009 causes LTO/PGO bootstrap failure: ICE: in inline_small_functions, at ipa-inline.c:1709)
2014-11-25 Martin Liska <mliska@suse.cz> PR bootstrap/64050 PR ipa/64060 * sreal.c (sreal::operator+): Addition fixed. (sreal::signedless_plus): Negative numbers are handled correctly. (sreal::operator-): Subtraction is fixed. (sreal::signedless_minus): Negative numbers are handled correctly. * sreal.h (sreal::operator<): Equal negative numbers are compared correctly. (sreal::shift): New checking asserts are introduced. Operation is fixed. * gcc.dg/plugin/plugin.exp: New plugin. * gcc.dg/plugin/sreal-test-1.c: New test. * gcc.dg/plugin/sreal_plugin.c: New test. From-SVN: r218048
Diffstat (limited to 'gcc/sreal.c')
-rw-r--r--gcc/sreal.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/gcc/sreal.c b/gcc/sreal.c
index 0337f9e..2b5e3ae 100644
--- a/gcc/sreal.c
+++ b/gcc/sreal.c
@@ -182,9 +182,9 @@ sreal::operator+ (const sreal &other) const
{
sreal tmp = -(*b_p);
if (*a_p < tmp)
- return signedless_minus (tmp, *a_p, false);
+ return signedless_minus (tmp, *a_p, true);
else
- return signedless_minus (*a_p, tmp, true);
+ return signedless_minus (*a_p, tmp, false);
}
gcc_checking_assert (a_p->m_negative == b_p->m_negative);
@@ -203,7 +203,7 @@ sreal::signedless_plus (const sreal &a, const sreal &b, bool negative)
const sreal *a_p = &a;
const sreal *b_p = &b;
- if (*a_p < *b_p)
+ if (a_p->m_exp < b_p->m_exp)
std::swap (a_p, b_p);
dexp = a_p->m_exp - b_p->m_exp;
@@ -211,6 +211,7 @@ sreal::signedless_plus (const sreal &a, const sreal &b, bool negative)
if (dexp > SREAL_BITS)
{
r.m_sig = a_p->m_sig;
+ r.m_negative = negative;
return r;
}
@@ -248,11 +249,11 @@ sreal::operator- (const sreal &other) const
/* We want to substract a smaller number from bigger
for nonegative numbers. */
if (!m_negative && *this < other)
- return -signedless_minus (other, *this, true);
+ return signedless_minus (other, *this, true);
/* Example: -2 - (-3) => 3 - 2 */
if (m_negative && *this > other)
- return signedless_minus (-other, -(*this), true);
+ return signedless_minus (-other, -(*this), false);
sreal r = signedless_minus (*this, other, m_negative);
@@ -274,6 +275,7 @@ sreal::signedless_minus (const sreal &a, const sreal &b, bool negative)
if (dexp > SREAL_BITS)
{
r.m_sig = a_p->m_sig;
+ r.m_negative = negative;
return r;
}
if (dexp == 0)