diff options
author | Jan Hubicka <jh@suse.cz> | 2018-08-30 14:58:42 +0200 |
---|---|---|
committer | Jan Hubicka <hubicka@gcc.gnu.org> | 2018-08-30 12:58:42 +0000 |
commit | a5f4d3d6a1379ad4a806e65b2fc7ac86bbaf72ae (patch) | |
tree | 36987055a6347d3f684dd6e9707d49cf4a97dd2b | |
parent | b1d5f644929182de05cf2bb940a6c417ec28f29a (diff) | |
download | gcc-a5f4d3d6a1379ad4a806e65b2fc7ac86bbaf72ae.zip gcc-a5f4d3d6a1379ad4a806e65b2fc7ac86bbaf72ae.tar.gz gcc-a5f4d3d6a1379ad4a806e65b2fc7ac86bbaf72ae.tar.bz2 |
sreal.h (SREAL_PART_BITS): Change to 31; remove seemingly unnecessary comment that it has to be even number.
* sreal.h (SREAL_PART_BITS): Change to 31; remove seemingly unnecessary
comment that it has to be even number.
(class sreal): Change m_sig type to int32_t.
* sreal.c (sreal::dump, sreal::to_int, opreator+, operator-): Use
int64_t for temporary calculations.
(sreal_verify_basics): Drop one bit from minimum and maximum.
From-SVN: r263981
-rw-r--r-- | gcc/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/sreal.c | 16 | ||||
-rw-r--r-- | gcc/sreal.h | 5 |
3 files changed, 19 insertions, 11 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e7a1910..86c96a9 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2018-08-29 Jan Hubicka <jh@suse.cz> + + * sreal.h (SREAL_PART_BITS): Change to 31; remove seemingly unnecessary + comment that it has to be even number. + (class sreal): Change m_sig type to int32_t. + * sreal.c (sreal::dump, sreal::to_int, opreator+, operator-): Use + int64_t for temporary calculations. + (sreal_verify_basics): Drop one bit from minimum and maximum. + 2018-08-30 Richard Biener <rguenther@suse.de> PR tree-optimization/87147 diff --git a/gcc/sreal.c b/gcc/sreal.c index 925b065..e17d93a 100644 --- a/gcc/sreal.c +++ b/gcc/sreal.c @@ -64,7 +64,7 @@ along with GCC; see the file COPYING3. If not see void sreal::dump (FILE *file) const { - fprintf (file, "(%" PRIi64 " * 2^%d)", m_sig, m_exp); + fprintf (file, "(%" PRIi64 " * 2^%d)", (int64_t)m_sig, m_exp); } DEBUG_FUNCTION void @@ -114,7 +114,7 @@ sreal::to_int () const if (m_exp >= SREAL_PART_BITS) return sign * INTTYPE_MAXIMUM (int64_t); if (m_exp > 0) - return sign * (SREAL_ABS (m_sig) << m_exp); + return sign * (SREAL_ABS ((int64_t)m_sig) << m_exp); if (m_exp < 0) return m_sig >> -m_exp; return m_sig; @@ -167,7 +167,7 @@ sreal::operator+ (const sreal &other) const bb = &tmp; } - r_sig = a_p->m_sig + bb->m_sig; + r_sig = a_p->m_sig + (int64_t)bb->m_sig; sreal r (r_sig, r_exp); return r; } @@ -211,7 +211,7 @@ sreal::operator- (const sreal &other) const bb = &tmp; } - r_sig = sign * ((int64_t) a_p->m_sig - bb->m_sig); + r_sig = sign * ((int64_t) a_p->m_sig - (int64_t)bb->m_sig); sreal r (r_sig, r_exp); return r; } @@ -277,15 +277,15 @@ namespace selftest { static void sreal_verify_basics (void) { - sreal minimum = INT_MIN; - sreal maximum = INT_MAX; + sreal minimum = INT_MIN/2; + sreal maximum = INT_MAX/2; sreal seven = 7; sreal minus_two = -2; sreal minus_nine = -9; - ASSERT_EQ (INT_MIN, minimum.to_int ()); - ASSERT_EQ (INT_MAX, maximum.to_int ()); + ASSERT_EQ (INT_MIN/2, minimum.to_int ()); + ASSERT_EQ (INT_MAX/2, maximum.to_int ()); ASSERT_FALSE (minus_two < minus_two); ASSERT_FALSE (seven < seven); diff --git a/gcc/sreal.h b/gcc/sreal.h index 6f841cf..e2ad1a3 100644 --- a/gcc/sreal.h +++ b/gcc/sreal.h @@ -20,8 +20,7 @@ along with GCC; see the file COPYING3. If not see #ifndef GCC_SREAL_H #define GCC_SREAL_H -/* SREAL_PART_BITS has to be an even number. */ -#define SREAL_PART_BITS 32 +#define SREAL_PART_BITS 31 #define UINT64_BITS 64 @@ -137,7 +136,7 @@ private: static sreal signedless_plus (const sreal &a, const sreal &b, bool negative); static sreal signedless_minus (const sreal &a, const sreal &b, bool negative); - int64_t m_sig; /* Significant. */ + int32_t m_sig; /* Significant. */ signed int m_exp; /* Exponent. */ }; |