aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2016-08-09 09:49:14 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2016-08-09 09:49:14 +0200
commit9e207d6fec83ee36458d59254d3fd40b3752bec2 (patch)
treef9c8a787b868065680fcf3982a8ae8846c37d368 /gcc
parent50bf47fdc08807bf8fc0362d677c8fc7dd4514b0 (diff)
downloadgcc-9e207d6fec83ee36458d59254d3fd40b3752bec2.zip
gcc-9e207d6fec83ee36458d59254d3fd40b3752bec2.tar.gz
gcc-9e207d6fec83ee36458d59254d3fd40b3752bec2.tar.bz2
re PR tree-optimization/72824 (Signed floating point zero semantics broken at optimization level -O3 (tree-loop-distribute-patterns))
PR tree-optimization/72824 * tree-loop-distribution.c (const_with_all_bytes_same): Verify real_zerop is not negative. * gcc.c-torture/execute/ieee/pr72824.c: New test. From-SVN: r239275
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/ieee/pr72824.c19
-rw-r--r--gcc/tree-loop-distribution.c30
4 files changed, 59 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 2d96f88..e71b5482 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2016-08-09 Jakub Jelinek <jakub@redhat.com>
+
+ PR tree-optimization/72824
+ * tree-loop-distribution.c (const_with_all_bytes_same): Verify
+ real_zerop is not negative.
+
2016-08-09 Richard Biener <rguenther@suse.de>
PR tree-optimization/71802
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 9ba1052..711778b 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2016-08-09 Jakub Jelinek <jakub@redhat.com>
+
+ PR tree-optimization/72824
+ * gcc.c-torture/execute/ieee/pr72824.c: New test.
+
2016-08-09 Richard Biener <rguenther@suse.de>
PR tree-optimization/71802
diff --git a/gcc/testsuite/gcc.c-torture/execute/ieee/pr72824.c b/gcc/testsuite/gcc.c-torture/execute/ieee/pr72824.c
new file mode 100644
index 0000000..1c21373
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/ieee/pr72824.c
@@ -0,0 +1,19 @@
+/* PR tree-optimization/72824 */
+
+static inline void
+foo (float *x, float value)
+{
+ int i;
+ for (i = 0; i < 32; ++i)
+ x[i] = value;
+}
+
+int
+main ()
+{
+ float x[32];
+ foo (x, -0.f);
+ if (__builtin_copysignf (1.0, x[3]) != -1.0f)
+ __builtin_abort ();
+ return 0;
+}
diff --git a/gcc/tree-loop-distribution.c b/gcc/tree-loop-distribution.c
index 181e4e9..342b964 100644
--- a/gcc/tree-loop-distribution.c
+++ b/gcc/tree-loop-distribution.c
@@ -750,12 +750,40 @@ const_with_all_bytes_same (tree val)
int i, len;
if (integer_zerop (val)
- || real_zerop (val)
|| (TREE_CODE (val) == CONSTRUCTOR
&& !TREE_CLOBBER_P (val)
&& CONSTRUCTOR_NELTS (val) == 0))
return 0;
+ if (real_zerop (val))
+ {
+ /* Only return 0 for +0.0, not for -0.0, which doesn't have
+ an all bytes same memory representation. Don't transform
+ -0.0 stores into +0.0 even for !HONOR_SIGNED_ZEROS. */
+ switch (TREE_CODE (val))
+ {
+ case REAL_CST:
+ if (!real_isneg (TREE_REAL_CST_PTR (val)))
+ return 0;
+ break;
+ case COMPLEX_CST:
+ if (!const_with_all_bytes_same (TREE_REALPART (val))
+ && !const_with_all_bytes_same (TREE_IMAGPART (val)))
+ return 0;
+ break;
+ case VECTOR_CST:
+ unsigned int j;
+ for (j = 0; j < VECTOR_CST_NELTS (val); ++j)
+ if (const_with_all_bytes_same (VECTOR_CST_ELT (val, i)))
+ break;
+ if (j == VECTOR_CST_NELTS (val))
+ return 0;
+ break;
+ default:
+ break;
+ }
+ }
+
if (CHAR_BIT != 8 || BITS_PER_UNIT != 8)
return -1;