]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: [multiple changes]
authorRichard Biener <rguenther@suse.de>
Thu, 7 Jul 2016 10:33:01 +0000 (10:33 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 7 Jul 2016 10:33:01 +0000 (10:33 +0000)
2016-07-07  Richard Biener  <rguenther@suse.de>

Backport from mainline
2016-06-07  Richard Biener  <rguenther@suse.de>

PR middle-end/71423
* match.pd ((X | ~Y) -> Y <= X): Properly invert the comparison
for signed ops.

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

2016-06-08  Richard Biener  <rguenther@suse.de>

PR tree-optimization/71452
* tree-ssa.c (non_rewritable_lvalue_p): Make sure that the
type used for the SSA rewrite has enough precision to cover
the dynamic type of the location.

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

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: r238084

gcc/ChangeLog
gcc/match.pd
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/torture/pr71452.C [new file with mode: 0644]
gcc/testsuite/gcc.dg/torture/pr71423.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/torture/pr71452.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/torture/pr71522.c [new file with mode: 0644]
gcc/tree-ssa.c

index 240676ae92fbf9975b370b3027775656c8056d9f..4db4ce65060afb131248e39fa9d7030e8a31d910 100644 (file)
@@ -1,3 +1,25 @@
+2016-07-07  Richard Biener  <rguenther@suse.de>
+
+       Backport from mainline
+       2016-06-07  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/71423
+       * match.pd ((X | ~Y) -> Y <= X): Properly invert the comparison
+       for signed ops.
+
+       2016-06-08  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/71452
+       * tree-ssa.c (non_rewritable_lvalue_p): Make sure that the
+       type used for the SSA rewrite has enough precision to cover
+       the dynamic type of the location.
+
+       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-07-01  Eric Botcazou  <ebotcazou@adacore.com>
 
        * config/arm/arm.c (arm_function_ok_for_sibcall): Add another check
index 405fec67789309b34a3c09d2e0a8b1f4e2b35cbf..a5f87b454732f808dbc57b77566bd1d89c4fd639 100644 (file)
@@ -370,12 +370,16 @@ along with GCC; see the file COPYING3.  If not see
   (ne (bit_and:c (bit_not @0) @1) integer_zerop)
   (if (INTEGRAL_TYPE_P (TREE_TYPE (@1))
        && TYPE_PRECISION (TREE_TYPE (@1)) == 1)
-   (lt @0 @1)))
+   (if (TYPE_UNSIGNED (TREE_TYPE (@1)))
+    (lt @0 @1))
+   (gt @0 @1)))
 (simplify
   (ne (bit_ior:c (bit_not @0) @1) integer_zerop)
   (if (INTEGRAL_TYPE_P (TREE_TYPE (@1))
        && TYPE_PRECISION (TREE_TYPE (@1)) == 1)
-   (le @0 @1)))
+   (if (TYPE_UNSIGNED (TREE_TYPE (@1)))
+    (le @0 @1))
+   (ge @0 @1)))
 
 /* ~~x -> x */
 (simplify
index 9b66e983d8bd4472338038b2274dac922aa56427..6baf1867e9f3dab0e9876b1add1312b1b19cf75f 100644 (file)
@@ -1,3 +1,21 @@
+2016-07-07  Richard Biener  <rguenther@suse.de>
+
+       Backport from mainline
+       2016-06-07  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/71423
+       * gcc.dg/torture/pr71423.c: New testcase.
+
+       2016-06-08  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/71452
+       * gcc.dg/torture/pr71452.c: New testcase.
+
+       2016-06-14  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/71522
+       * gcc.dg/torture/pr71522.c: New testcase.
+
 2016-06-30  Jakub Jelinek  <jakub@redhat.com>
 
        PR middle-end/71693
diff --git a/gcc/testsuite/g++.dg/torture/pr71452.C b/gcc/testsuite/g++.dg/torture/pr71452.C
new file mode 100644 (file)
index 0000000..3ebe3a1
--- /dev/null
@@ -0,0 +1,10 @@
+// { dg-do run }
+
+int main()
+{
+  bool b;
+  *(char *)&b = 123;
+  if (*(char *)&b != 123)
+    __builtin_abort ();
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr71423.c b/gcc/testsuite/gcc.dg/torture/pr71423.c
new file mode 100644 (file)
index 0000000..06a613f
--- /dev/null
@@ -0,0 +1,20 @@
+/* { dg-do run } */
+
+struct S1
+{
+  int f1:1;
+};
+
+volatile struct S1 b = { 0 };
+
+int
+main ()
+{
+  char c = b.f1;
+  b.f1 = 1; 
+
+  if (b.f1 > -1 || c)
+    __builtin_abort (); 
+
+  return 0; 
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr71452.c b/gcc/testsuite/gcc.dg/torture/pr71452.c
new file mode 100644 (file)
index 0000000..8948d39
--- /dev/null
@@ -0,0 +1,10 @@
+/* { dg-do run } */
+
+int main()
+{
+  _Bool b;
+  *(char *)&b = 123;
+  if (*(char *)&b != 123)
+    __builtin_abort ();
+  return 0;
+}
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 68ce43a719e771e049079f08d1ca7052e89fb634..a3c0c0d8156245a2c16099e2bf8097a174eacb4c 100644 (file)
@@ -1354,6 +1354,18 @@ non_rewritable_lvalue_p (tree lhs)
       tree decl = TREE_OPERAND (TREE_OPERAND (lhs, 0), 0);
       if (DECL_P (decl)
          && DECL_SIZE (decl) == TYPE_SIZE (TREE_TYPE (lhs))
+         /* If the dynamic type of the decl has larger precision than
+            the decl itself we can't use the decls type for SSA rewriting.  */
+         && ((! INTEGRAL_TYPE_P (TREE_TYPE (decl))
+              || compare_tree_int (DECL_SIZE (decl),
+                                   TYPE_PRECISION (TREE_TYPE (decl))) == 0)
+             || (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;
     }