re PR tree-optimization/71522 (Wrong optimization of memcpy through a var of type...
authorRichard Biener <rguenther@suse.de>
Tue, 14 Jun 2016 10:42:00 +0000 (10:42 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 14 Jun 2016 10:42:00 +0000 (10:42 +0000)
2016-06-14  Richard Biener  <rguenther@suse.de>

PR tree-optimization/71522
* tree-ssa.c (non_rewritable_lvalue_p): Do not rewrite non-float
copying into float copying.

* gcc.dg/torture/pr71522.c: New testcase.

From-SVN: r237429

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr71522.c [new file with mode: 0644]
gcc/tree-ssa.c

index 1a3e5fdd907b5256e9c9787126e309ec30c37818..990444312d0fb0f789d62df6e95788726586f853 100644 (file)
@@ -1,3 +1,9 @@
+2016-06-14  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/71522
+       * tree-ssa.c (non_rewritable_lvalue_p): Do not rewrite non-float
+       copying into float copying.
+
 2016-06-14  Jakub Jelinek  <jakub@redhat.com>
 
        PR tree-optimization/71520
index 9b38c06854c1e074bd127ce723d466713a73f532..dfe4fb766b1b2c77f3b9d9e58c03941438dbefa2 100644 (file)
@@ -1,3 +1,8 @@
+2016-06-14  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/71522
+       * gcc.dg/torture/pr71522.c: New testcase.
+
 2016-06-14  Jakub Jelinek  <jakub@redhat.com>
 
        PR tree-optimization/71520
diff --git a/gcc/testsuite/gcc.dg/torture/pr71522.c b/gcc/testsuite/gcc.dg/torture/pr71522.c
new file mode 100644 (file)
index 0000000..953c4c7
--- /dev/null
@@ -0,0 +1,27 @@
+/* { dg-do run } */
+
+#if __SIZEOF_LONG_DOUBLE__ == 16
+#define STR "AAAAAAAAAAAAAAA"
+#elif __SIZEOF_LONG_DOUBLE__ == 12
+#define STR "AAAAAAAAAAA"
+#elif __SIZEOF_LONG_DOUBLE__ == 8
+#define STR "AAAAAAA"
+#elif __SIZEOF_LONG_DOUBLE__ == 4
+#define STR "AAA"
+#else
+#define STR "A"
+#endif
+
+int main()
+{
+  long double d;
+  char s[sizeof d];
+
+  __builtin_memcpy(&d, STR, sizeof d);
+  __builtin_memcpy(&s, &d, sizeof s);
+
+  if (__builtin_strncmp (s, STR, sizeof s) != 0)
+    __builtin_abort ();
+
+  return 0;
+}
index 30c6269e34530a1a11d8e04aeabc900239bce3db..247fa0717dd242f3e55e3cd305633612978ac99b 100644 (file)
@@ -1300,6 +1300,10 @@ non_rewritable_lvalue_p (tree lhs)
              || (INTEGRAL_TYPE_P (TREE_TYPE (lhs))
                  && (TYPE_PRECISION (TREE_TYPE (decl))
                      >= TYPE_PRECISION (TREE_TYPE (lhs)))))
+         /* Make sure we are not re-writing non-float copying into float
+            copying as that can incur normalization.  */
+         && (! FLOAT_TYPE_P (TREE_TYPE (decl))
+             || types_compatible_p (TREE_TYPE (lhs), TREE_TYPE (decl)))
          && (TREE_THIS_VOLATILE (decl) == TREE_THIS_VOLATILE (lhs)))
        return false;