aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree.c
diff options
context:
space:
mode:
authorRoger Sayle <roger@eyesopen.com>2003-10-03 21:33:57 +0000
committerRoger Sayle <sayle@gcc.gnu.org>2003-10-03 21:33:57 +0000
commit875eda9c345e57676c4f21f753274ee51025fa41 (patch)
tree09c0fbd9595e9411be41c39493368c74ad3a13be /gcc/tree.c
parent4dbe1556cce68a32108fbad54c6e445240f8bb4b (diff)
downloadgcc-875eda9c345e57676c4f21f753274ee51025fa41.zip
gcc-875eda9c345e57676c4f21f753274ee51025fa41.tar.gz
gcc-875eda9c345e57676c4f21f753274ee51025fa41.tar.bz2
PR optimization/9325, PR java/6391
PR optimization/9325, PR java/6391 * fold-const.c (fold_convert): For floating point to integer conversions, return the maximum/minimum representable integer value if the real constant overflows the destination type. * tree.c (real_value_from_int_cst): Allow the type to be NULL, meaning don't truncate the result to a floating point mode. Simplify the logic by calling real_from_integer directly. * simplify-rtx.c (simplify_unary_operation): Implement the same semantics for folding floating point to integer conversions in RTL. * gcc.c-torture/execute/20031003-1.c: New test case. From-SVN: r72079
Diffstat (limited to 'gcc/tree.c')
-rw-r--r--gcc/tree.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/gcc/tree.c b/gcc/tree.c
index b82a6bf..c83b240 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -488,7 +488,7 @@ build_real (tree type, REAL_VALUE_TYPE d)
and whose value is the integer value of the INTEGER_CST node I. */
REAL_VALUE_TYPE
-real_value_from_int_cst (tree type ATTRIBUTE_UNUSED, tree i)
+real_value_from_int_cst (tree type, tree i)
{
REAL_VALUE_TYPE d;
@@ -496,12 +496,9 @@ real_value_from_int_cst (tree type ATTRIBUTE_UNUSED, tree i)
bitwise comparisons to see if two values are the same. */
memset (&d, 0, sizeof d);
- if (! TREE_UNSIGNED (TREE_TYPE (i)))
- REAL_VALUE_FROM_INT (d, TREE_INT_CST_LOW (i), TREE_INT_CST_HIGH (i),
- TYPE_MODE (type));
- else
- REAL_VALUE_FROM_UNSIGNED_INT (d, TREE_INT_CST_LOW (i),
- TREE_INT_CST_HIGH (i), TYPE_MODE (type));
+ real_from_integer (&d, type ? TYPE_MODE (type) : VOIDmode,
+ TREE_INT_CST_LOW (i), TREE_INT_CST_HIGH (i),
+ TREE_UNSIGNED (TREE_TYPE (i)));
return d;
}