diff options
author | hubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-12-15 22:03:11 +0000 |
---|---|---|
committer | hubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-12-15 22:03:11 +0000 |
commit | eb9db6cecb077936a6e4a28bccb784bc83785d3b (patch) | |
tree | 47e5dd490ff7e0e1fe6e3f4282b7c591b9d7503b | |
parent | 72666aed4013109675291d58cc631ba74cf3c4d9 (diff) | |
download | gcc-eb9db6cecb077936a6e4a28bccb784bc83785d3b.tar.gz |
* sreal.h (to_double): New method.
(shift): Do not ICE on 0.
* sreal.c: Include math.h
(sreal::to_double): New.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@218765 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/sreal.c | 13 | ||||
-rw-r--r-- | gcc/sreal.h | 9 |
3 files changed, 26 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 07aa48c4ba5..e050f032757 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2014-12-15 Jan Hubicka <hubicka@ucw.cz> + + * sreal.h (to_double): New method. + (shift): Do not ICE on 0. + * sreal.c: Include math.h + (sreal::to_double): New. + 2014-12-15 Jakub Jelinek <jakub@redhat.com> PR rtl-optimization/64316 diff --git a/gcc/sreal.c b/gcc/sreal.c index bc3af2309db..10de80b7702 100644 --- a/gcc/sreal.c +++ b/gcc/sreal.c @@ -47,6 +47,7 @@ along with GCC; see the file COPYING3. If not see sig == 0 && exp == -SREAL_MAX_EXP */ +#include <math.h> #include "config.h" #include "system.h" #include "coretypes.h" @@ -171,6 +172,18 @@ sreal::to_int () const return m_sig; } +/* Return value of *this as double. + This should be used for debug output only. */ + +double +sreal::to_double () const +{ + double val = m_sig; + if (m_exp) + val *= exp2 (m_exp); + return val; +} + /* Return *this + other. */ sreal diff --git a/gcc/sreal.h b/gcc/sreal.h index 730f49c4d89..6314cea0fc4 100644 --- a/gcc/sreal.h +++ b/gcc/sreal.h @@ -46,6 +46,7 @@ public: void dump (FILE *) const; int64_t to_int () const; + double to_double () const; sreal operator+ (const sreal &other) const; sreal operator- (const sreal &other) const; sreal operator* (const sreal &other) const; @@ -83,12 +84,14 @@ public: sreal shift (int s) const { + /* Zero needs no shifting. */ + if (!m_sig) + return *this; gcc_checking_assert (s <= SREAL_BITS); gcc_checking_assert (s >= -SREAL_BITS); - /* Exponent should never be so large because shift_right is used only by - sreal_add and sreal_sub ant thus the number cannot be shifted out from - exponent range. */ + /* Overflows/drop to 0 could be handled gracefully, but hopefully we do not + need to do so. */ gcc_checking_assert (m_exp + s <= SREAL_MAX_EXP); gcc_checking_assert (m_exp + s >= -SREAL_MAX_EXP); |