diff options
author | Yury Gribov <tetra2005@gmail.com> | 2018-10-12 20:35:20 +0000 |
---|---|---|
committer | Yury Gribov <ygribov@gcc.gnu.org> | 2018-10-12 20:35:20 +0000 |
commit | e41ec71bd97a1a8eaef40695c7ae9b7f4b1fc819 (patch) | |
tree | d9f2071404e3120d9043af8e3800ed5d14c14b8c /gcc/real.c | |
parent | 67aeaded2f8dabe16b4879261c6b6ddda6b53cd2 (diff) | |
download | gcc-e41ec71bd97a1a8eaef40695c7ae9b7f4b1fc819.zip gcc-e41ec71bd97a1a8eaef40695c7ae9b7f4b1fc819.tar.gz gcc-e41ec71bd97a1a8eaef40695c7ae9b7f4b1fc819.tar.bz2 |
Add pattern to remove useless float casts in comparisons.
PR middle-end/81376
gcc/
* real.c (format_helper::can_represent_integral_type_p): New function
* real.h (format_helper::can_represent_integral_type_p): Ditto.
* match.pd: New pattern.
gcc/testsuite/
* c-c++-common/pr81376.c: New test.
* gcc.target/i386/387-ficom-2.c: Update test.
* gcc.target/i386/387-ficom-2.c: Ditto.
From-SVN: r265131
Diffstat (limited to 'gcc/real.c')
-rw-r--r-- | gcc/real.c | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -5176,6 +5176,19 @@ get_max_float (const struct real_format *fmt, char *buf, size_t len) gcc_assert (strlen (buf) < len); } +/* True if all values of integral type can be represented + by this floating-point type exactly. */ + +bool format_helper::can_represent_integral_type_p (tree type) const +{ + gcc_assert (! decimal_p () && INTEGRAL_TYPE_P (type)); + + /* INT?_MIN is power-of-two so it takes + only one mantissa bit. */ + bool signed_p = TYPE_SIGN (type) == SIGNED; + return TYPE_PRECISION (type) - signed_p <= significand_size (*this); +} + /* True if mode M has a NaN representation and the treatment of NaN operands is important. */ |