diff options
author | sayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-05-23 03:46:53 +0000 |
---|---|---|
committer | sayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-05-23 03:46:53 +0000 |
commit | ac4bd9a0eed8a2ccbbaee8480dba1e3a646458cc (patch) | |
tree | 5b38df8d0da0fa5e04c432815e2f600b41d5f2e5 /gcc/real.c | |
parent | 07fea4789bd395e94460b94cceac2e1f925dd607 (diff) | |
download | gcc-ac4bd9a0eed8a2ccbbaee8480dba1e3a646458cc.tar.gz |
* real.c (real_maxval): New function to return the largest finite
value representable in a given mode (i.e. FLT_MAX and DBL_MAX).
* real.h (real_maxval): Prototype here.
* fold-const.c (fold_inf_compare): Transform comparisons against
+-Infinity into comparisons against DBL_MAX (or equivalent).
* gcc.c-torture/execute/ieee/inf-2.c: New test case.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@67112 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/real.c')
-rw-r--r-- | gcc/real.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/gcc/real.c b/gcc/real.c index 16cd02acb7f..4a4b04012ce 100644 --- a/gcc/real.c +++ b/gcc/real.c @@ -2280,6 +2280,33 @@ real_nan (r, str, quiet, mode) return true; } +/* Fills R with the largest finite value representable in mode MODE. + If SIGN is non-zero, R is set to the most negative finite value. */ + +void +real_maxval (r, sign, mode) + REAL_VALUE_TYPE *r; + int sign; + enum machine_mode mode; +{ + const struct real_format *fmt; + int np2; + + fmt = real_format_for_mode[mode - QFmode]; + if (fmt == NULL) + abort (); + + r->class = rvc_normal; + r->sign = sign; + r->signalling = 0; + r->canonical = 0; + r->exp = fmt->emax * fmt->log2_b; + + np2 = SIGNIFICAND_BITS - fmt->p * fmt->log2_b; + memset (r->sig, -1, SIGSZ * sizeof (unsigned long)); + clear_significand_below (r, np2); +} + /* Fills R with 2**N. */ void |