aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2008-10-29 17:05:42 +0000
committerJoseph Myers <jsm28@gcc.gnu.org>2008-10-29 17:05:42 +0000
commit20ded7a68b10f9c2d1aaa94e89df494bf0ce41a0 (patch)
treef0bc48b745fe374d4990579d0ef02a2d88bb7799 /gcc/testsuite
parent669eeb28eaad6f3cb79d48a5e4176775befe0429 (diff)
downloadgcc-20ded7a68b10f9c2d1aaa94e89df494bf0ce41a0.zip
gcc-20ded7a68b10f9c2d1aaa94e89df494bf0ce41a0.tar.gz
gcc-20ded7a68b10f9c2d1aaa94e89df494bf0ce41a0.tar.bz2
re PR middle-end/36578 (cast to long double not taken into account when result stored to a double)
PR middle-end/36578 * convert.c (convert_to_real): Do not optimize conversions of binary arithmetic operations between binary and decimal floating-point types. Consider mode of target type in determining decimal type for arithmetic. Unless flag_unsafe_math_optimizations, do not optimize binary conversions where this may change rounding behavior. * real.c (real_can_shorten_arithmetic): New. * real.h (real_can_shorten_arithmetic): Declare. testsuite: * gcc.dg/dfp/convert-bfp-13.c, gcc.dg/dfp/convert-bfp-14.c, gcc.dg/dfp/convert-dfp-fold-2.c, gcc.target/i386/pr36578-1.c, gcc.target/i386/pr36578-2.c: New tests. From-SVN: r141432
Diffstat (limited to 'gcc/testsuite')
-rw-r--r--gcc/testsuite/ChangeLog7
-rw-r--r--gcc/testsuite/gcc.dg/dfp/convert-bfp-13.c20
-rw-r--r--gcc/testsuite/gcc.dg/dfp/convert-bfp-14.c17
-rw-r--r--gcc/testsuite/gcc.dg/dfp/convert-dfp-fold-2.c17
-rw-r--r--gcc/testsuite/gcc.target/i386/pr36578-1.c22
-rw-r--r--gcc/testsuite/gcc.target/i386/pr36578-2.c23
6 files changed, 106 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 0708401..6e3f6f2 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,10 @@
+2008-10-29 Joseph Myers <joseph@codesourcery.com>
+
+ PR middle-end/36578
+ * gcc.dg/dfp/convert-bfp-13.c, gcc.dg/dfp/convert-bfp-14.c,
+ gcc.dg/dfp/convert-dfp-fold-2.c, gcc.target/i386/pr36578-1.c,
+ gcc.target/i386/pr36578-2.c: New tests.
+
2008-10-29 Jakub Jelinek <jakub@redhat.com>
PR middle-end/37870
diff --git a/gcc/testsuite/gcc.dg/dfp/convert-bfp-13.c b/gcc/testsuite/gcc.dg/dfp/convert-bfp-13.c
new file mode 100644
index 0000000..91a5b49
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/dfp/convert-bfp-13.c
@@ -0,0 +1,20 @@
+/* Test for bug where fold changed binary operation to decimal
+ depending on typedefs. */
+/* { dg-options "-std=gnu99" } */
+
+extern void abort (void);
+extern void exit (int);
+
+volatile double d = 1.2345675;
+
+typedef const volatile _Decimal32 d32;
+
+int
+main (void)
+{
+ _Decimal32 a = (d * d);
+ d32 b = (d * d);
+ if (a != b)
+ abort ();
+ exit (0);
+}
diff --git a/gcc/testsuite/gcc.dg/dfp/convert-bfp-14.c b/gcc/testsuite/gcc.dg/dfp/convert-bfp-14.c
new file mode 100644
index 0000000..a1312d2a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/dfp/convert-bfp-14.c
@@ -0,0 +1,17 @@
+/* Test for bug where fold narrowed decimal floating-point
+ operations. */
+/* { dg-options "-std=gnu99" } */
+
+extern void abort (void);
+extern void exit (int);
+
+volatile _Decimal32 f = 1.23456DF;
+volatile _Decimal64 d = 1.23456DD;
+
+int
+main (void)
+{
+ if ((double)((_Decimal64)f * (_Decimal64)f) != (double)(d * d))
+ abort ();
+ exit (0);
+}
diff --git a/gcc/testsuite/gcc.dg/dfp/convert-dfp-fold-2.c b/gcc/testsuite/gcc.dg/dfp/convert-dfp-fold-2.c
new file mode 100644
index 0000000..9f09279
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/dfp/convert-dfp-fold-2.c
@@ -0,0 +1,17 @@
+/* Test for bug where fold narrowed decimal floating-point
+ operations. */
+/* { dg-options "-std=gnu99" } */
+
+extern void abort (void);
+extern void exit (int);
+
+volatile _Decimal32 f = 1.23456DF;
+volatile _Decimal64 d = 1.23456DD;
+
+int
+main (void)
+{
+ if ((_Decimal128)((_Decimal64)f * (_Decimal64)f) != (_Decimal128)(d * d))
+ abort ();
+ exit (0);
+}
diff --git a/gcc/testsuite/gcc.target/i386/pr36578-1.c b/gcc/testsuite/gcc.target/i386/pr36578-1.c
new file mode 100644
index 0000000..cae0d70
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr36578-1.c
@@ -0,0 +1,22 @@
+/* Test for unsafe floating-point conversions. PR 36578. */
+/* { dg-do run } */
+/* { dg-options "-msse2 -mfpmath=sse" } */
+
+#include "sse2-check.h"
+
+extern void abort (void);
+extern void exit (int);
+extern int printf(const char *, ...);
+
+volatile double d1 = 1.0;
+volatile double d2 = 0x1.00001p-53;
+volatile double d3;
+
+static void
+sse2_test (void)
+{
+ d3 = (double)((long double)d1 + (long double)d2);
+ if (d3 != d1)
+ abort ();
+ exit (0);
+}
diff --git a/gcc/testsuite/gcc.target/i386/pr36578-2.c b/gcc/testsuite/gcc.target/i386/pr36578-2.c
new file mode 100644
index 0000000..19143cf
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr36578-2.c
@@ -0,0 +1,23 @@
+/* Test for unsafe floating-point conversions. */
+/* { dg-do run } */
+/* { dg-options "-msse2 -mfpmath=sse" } */
+
+#include "sse2-check.h"
+
+extern void abort (void);
+extern void exit (int);
+extern int printf(const char *, ...);
+
+volatile double d1 = 0x1.000001p0;
+volatile double d2 = 0x1p-54;
+volatile float f = 0x1.000002p0f;
+volatile float f2;
+
+static void
+sse2_test (void)
+{
+ f2 = (float)((long double)d1 + (long double)d2);
+ if (f != f2)
+ abort ();
+ exit (0);
+}