diff options
author | Kaveh R. Ghazi <ghazi@caip.rutgers.edu> | 2007-07-18 17:30:38 +0000 |
---|---|---|
committer | Kaveh Ghazi <ghazi@gcc.gnu.org> | 2007-07-18 17:30:38 +0000 |
commit | 7faa1bbb5d0206cc83f20c1145f612f7754fdcf3 (patch) | |
tree | eb2db58c64bbaba8f0181d8d24ef99a386911de5 /gcc/real.c | |
parent | b5d32c25372d1e0604bbd8471d735e46215dbe03 (diff) | |
download | gcc-7faa1bbb5d0206cc83f20c1145f612f7754fdcf3.tar.gz |
re PR target/30652 (SSE expansion is missing for isinf() and other fpclassify functions)
PR target/30652
PR middle-end/20558
* builtins.c (expand_builtin_interclass_mathfn): Provide a
generic fallback for isinf.
* c-cppbuiltin.c (builtin_define_float_constants): Move FP max
calculation code ...
* real.c (get_max_float): ... to here.
* real.h (get_max_float): New.
testsuite:
* gcc.dg/pr28796-1.c: Add more cases.
* gcc.dg/pr28796-2.c: Likewise.
From-SVN: r126724
Diffstat (limited to 'gcc/real.c')
-rw-r--r-- | gcc/real.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/gcc/real.c b/gcc/real.c index b4d617f94d6..258ecf6635b 100644 --- a/gcc/real.c +++ b/gcc/real.c @@ -4835,3 +4835,35 @@ real_isinteger (const REAL_VALUE_TYPE *c, enum machine_mode mode) real_trunc (&cint, mode, c); return real_identical (c, &cint); } + +/* Write into BUF the maximum representable finite floating-point + number, (1 - b**-p) * b**emax for a given FP format FMT as a hex + float string. LEN is the size of BUF, and the buffer must be large + enough to contain the resulting string. */ + +void +get_max_float (const struct real_format *fmt, char *buf, size_t len) +{ + int i, n; + char *p; + + strcpy (buf, "0x0."); + n = fmt->p; + for (i = 0, p = buf + 4; i + 3 < n; i += 4) + *p++ = 'f'; + if (i < n) + *p++ = "08ce"[n - i]; + sprintf (p, "p%d", fmt->emax); + if (fmt->pnan < fmt->p) + { + /* This is an IBM extended double format made up of two IEEE + doubles. The value of the long double is the sum of the + values of the two parts. The most significant part is + required to be the value of the long double rounded to the + nearest double. Rounding means we need a slightly smaller + value for LDBL_MAX. */ + buf[4 + fmt->pnan / 4] = "7bde"[fmt->pnan % 4]; + } + + gcc_assert (strlen (buf) < len); +} |