aboutsummaryrefslogtreecommitdiff
path: root/gcc/fold-const.c
diff options
context:
space:
mode:
authorJan Hubicka <jh@suse.cz>2003-01-14 14:03:47 +0100
committerJan Hubicka <hubicka@gcc.gnu.org>2003-01-14 13:03:47 +0000
commit77f9af81d26ddde9326b63bfc2eefa557aba064e (patch)
treec3eb54b4346a9236a335d6192b4c3fb9db3e36ae /gcc/fold-const.c
parentab5496c4035e9c83e00e4ee1c87b410e6ca2c4e5 (diff)
downloadgcc-77f9af81d26ddde9326b63bfc2eefa557aba064e.zip
gcc-77f9af81d26ddde9326b63bfc2eefa557aba064e.tar.gz
gcc-77f9af81d26ddde9326b63bfc2eefa557aba064e.tar.bz2
convert.c (strip_float_extensions): Look for narrowest type handling FP constants.
* convert.c (strip_float_extensions): Look for narrowest type handling FP constants. * fold-const.c (fold): Fold (double)float1 CMP (double)float2 into float1 CMP float2. * convert.c (strip_float_extensions): Make global. * tree.h (strip_float_extensions): Declare. * gcc.dg/i386-fpcvt-1.c: New test. * gcc.dg/i386-fpcvt-2.c: New test. From-SVN: r61279
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r--gcc/fold-const.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 3847fc0..726e845 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -6041,6 +6041,18 @@ fold (expr)
if (FLOAT_TYPE_P (TREE_TYPE (arg0)))
{
+ tree targ0 = strip_float_extensions (arg0);
+ tree targ1 = strip_float_extensions (arg1);
+ tree newtype = TREE_TYPE (targ0);
+
+ if (TYPE_PRECISION (TREE_TYPE (targ1)) > TYPE_PRECISION (newtype))
+ newtype = TREE_TYPE (targ1);
+
+ /* Fold (double)float1 CMP (double)float2 into float1 CMP float2. */
+ if (TYPE_PRECISION (newtype) < TYPE_PRECISION (TREE_TYPE (arg0)))
+ return fold (build (code, type, convert (newtype, targ0),
+ convert (newtype, targ1)));
+
/* (-a) CMP (-b) -> b CMP a */
if (TREE_CODE (arg0) == NEGATE_EXPR
&& TREE_CODE (arg1) == NEGATE_EXPR)