aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite
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/testsuite
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/testsuite')
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/20031003-1.c42
2 files changed, 47 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 66b71f5..7e10c01 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2003-10-03 Roger Sayle <roger@eyesopen.com>
+
+ PR optimization/9325, PR java/6391
+ * gcc.c-torture/execute/20031003-1.c: New test case.
+
2003-10-02 Mark Mitchell <mark@codesourcery.com>
PR optimization/12180
diff --git a/gcc/testsuite/gcc.c-torture/execute/20031003-1.c b/gcc/testsuite/gcc.c-torture/execute/20031003-1.c
new file mode 100644
index 0000000..b60711f
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/20031003-1.c
@@ -0,0 +1,42 @@
+/* PR optimization/9325 */
+
+extern void abort (void);
+
+int f1()
+{
+ return (int)2147483648.0f;
+}
+
+int f2()
+{
+ return (int)(float)(2147483647);
+}
+
+int f3()
+{
+ float a = 2147483648.0f;
+ return (int)a;
+}
+
+int f4()
+{
+ int a = 2147483647;
+ float b = (float)a;
+ return (int)b;
+}
+
+int main()
+{
+ if (f1() != 2147483647)
+ abort ();
+ if (f2() != 2147483647)
+ abort ();
+#ifdef __OPTIMIZE__
+ if (f3() != 2147483647)
+ abort ();
+ if (f4() != 2147483647)
+ abort ();
+#endif
+ return 0;
+}
+