aboutsummaryrefslogtreecommitdiff
path: root/gcc/real.c
diff options
context:
space:
mode:
authorRoger Sayle <roger@eyesopen.com>2003-05-23 03:46:53 +0000
committerRoger Sayle <roger@eyesopen.com>2003-05-23 03:46:53 +0000
commitc0dec68e3505d39e363ca4ee9c977b0909c07eb0 (patch)
tree5b38df8d0da0fa5e04c432815e2f600b41d5f2e5 /gcc/real.c
parente620a87ca4fa92cbb67324d714e599a89d0ffc2b (diff)
* 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: https://gcc.gnu.org/svn/gcc/trunk@67112 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/real.c')
-rw-r--r--gcc/real.c27
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