]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Backport PRs 70022, 70484, 70931, 71452
authorRichard Biener <rguenther@suse.de>
Thu, 7 Jul 2016 11:46:08 +0000 (11:46 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 7 Jul 2016 11:46:08 +0000 (11:46 +0000)
2016-07-07  Richard Biener  <rguenther@suse.de>

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

PR rtl-optimization/70484
* rtl.h (canon_output_dependence): Declare.
* alias.c (canon_output_dependence): New function.
* dse.c (record_store): Use canon_output_dependence rather
than canon_true_dependence.

* gcc.dg/torture/pr70484.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-05-06  Richard Biener  <rguenther@suse.de>

PR middle-end/70931
* dwarf2out.c (native_encode_initializer): Skip zero-sized fields.

* gfortran.dg/pr70931.f90: New testcase.

2016-03-01  Richard Biener  <rguenther@suse.de>

PR middle-end/70022
* fold-const.c (fold_indirect_ref_1): Fix range checking for
vector BIT_FIELD_REF extract.

* gcc.dg/pr70022.c: New testcase.

From-SVN: r238087

13 files changed:
gcc/ChangeLog
gcc/alias.c
gcc/dse.c
gcc/dwarf2out.c
gcc/fold-const.c
gcc/rtl.h
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/torture/pr71452.C [new file with mode: 0644]
gcc/testsuite/gcc.dg/pr70022.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/torture/pr70484.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/torture/pr71452.c [new file with mode: 0644]
gcc/testsuite/gfortran.dg/pr70931.f90 [new file with mode: 0644]
gcc/tree-ssa.c

index 725d5aac29fc9560d05a62031cff13e509f95766..78a009c3a458dc076f6075b6334006196da5fd69 100644 (file)
@@ -1,3 +1,32 @@
+2016-07-07  Richard Biener  <rguenther@suse.de>
+
+       Backport from mainline
+       2016-04-04  Richard Biener  <rguenther@suse.de>
+
+       PR rtl-optimization/70484
+       * rtl.h (canon_output_dependence): Declare.
+       * alias.c (canon_output_dependence): New function.
+       * dse.c (record_store): Use canon_output_dependence rather
+       than canon_true_dependence.
+
+       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-05-06  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/70931
+       * dwarf2out.c (native_encode_initializer): Skip zero-sized fields.
+
+       2016-03-01  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/70022
+       * fold-const.c (fold_indirect_ref_1): Fix range checking for
+       vector BIT_FIELD_REF extract.
+
 2016-06-30  Jakub Jelinek  <jakub@redhat.com>
 
        PR middle-end/71693
index a1e554058d770f79e60bfb541bfe3725ffcf844d..2711b7df5b46d5cc3d3dd489f4f3225dc4d8a839 100644 (file)
@@ -2746,6 +2746,20 @@ output_dependence (const_rtx mem, const_rtx x)
                             /*mem_canonicalized=*/false,
                             /*x_canonicalized*/false, /*writep=*/true);
 }
+
+/* Likewise, but we already have a canonicalized MEM, and X_ADDR for X.
+   Also, consider X in X_MODE (which might be from an enclosing
+   STRICT_LOW_PART / ZERO_EXTRACT).
+   If MEM_CANONICALIZED is true, MEM is canonicalized.  */
+
+int
+canon_output_dependence (const_rtx mem, bool mem_canonicalized,
+                        const_rtx x, machine_mode x_mode, rtx x_addr)
+{
+  return write_dependence_p (mem, x, x_mode, x_addr,
+                            mem_canonicalized, /*x_canonicalized=*/true,
+                            /*writep=*/true);
+}
 \f
 
 
index 8ebf63f046e0164625ff73822cbe68b9f830e4be..9392f6bccc1b16f5b36806f479441e97aac669dd 100644 (file)
--- a/gcc/dse.c
+++ b/gcc/dse.c
@@ -1639,10 +1639,9 @@ record_store (rtx body, bb_info_t bb_info)
           the value of store_info.  If it is, set the rhs to NULL to
           keep it from being used to remove a load.  */
        {
-         if (canon_true_dependence (s_info->mem,
-                                    GET_MODE (s_info->mem),
-                                    s_info->mem_addr,
-                                    mem, mem_addr))
+         if (canon_output_dependence (s_info->mem, true,
+                                      mem, GET_MODE (mem),
+                                      mem_addr))
            {
              s_info->rhs = NULL;
              s_info->const_rhs = NULL;
index 6b4e83ad566056d89f07855588d4b7edab1c9b6a..f3226b62b46b78dd3d6adf072b382c63f65bdf47 100644 (file)
@@ -15817,7 +15817,7 @@ native_encode_initializer (tree init, unsigned char *array, int size)
              fieldsize = tree_to_shwi (DECL_SIZE_UNIT (field));
              pos = int_byte_position (field);
              gcc_assert (pos + fieldsize <= size);
-             if (val
+             if (val && fieldsize != 0
                  && !native_encode_initializer (val, array + pos, fieldsize))
                return false;
            }
index 0f284020d49dd23b6d07b00a8503670537980a29..61bbf82e169c4bca717e3c24959483ae3a40289a 100644 (file)
@@ -16742,17 +16742,20 @@ fold_indirect_ref_1 (location_t loc, tree type, tree op0)
          if (TREE_CODE (op00type) == VECTOR_TYPE
              && type == TREE_TYPE (op00type))
            {
-             HOST_WIDE_INT offset = tree_to_shwi (op01);
              tree part_width = TYPE_SIZE (type);
-             unsigned HOST_WIDE_INT part_widthi = tree_to_shwi (part_width)/BITS_PER_UNIT;
-             unsigned HOST_WIDE_INT indexi = offset * BITS_PER_UNIT;
-             tree index = bitsize_int (indexi);
-
-             if (offset / part_widthi < TYPE_VECTOR_SUBPARTS (op00type))
-               return fold_build3_loc (loc,
-                                       BIT_FIELD_REF, type, op00,
-                                       part_width, index);
-
+             unsigned HOST_WIDE_INT max_offset
+               = (tree_to_uhwi (part_width) / BITS_PER_UNIT
+                  * TYPE_VECTOR_SUBPARTS (op00type));
+             if (tree_int_cst_sign_bit (op01) == 0
+                 && compare_tree_int (op01, max_offset) == -1)
+               {
+                 unsigned HOST_WIDE_INT offset = tree_to_uhwi (op01);
+                 unsigned HOST_WIDE_INT indexi = offset * BITS_PER_UNIT;
+                 tree index = bitsize_int (indexi);
+                 return fold_build3_loc (loc,
+                                         BIT_FIELD_REF, type, op00,
+                                         part_width, index);
+               }
            }
          /* ((foo*)&complexfoo)[1] => __imag__ complexfoo */
          else if (TREE_CODE (op00type) == COMPLEX_TYPE
index f1cda4c04b59a94829c6841341ecdd7b4242aae6..722ec796b3e05aee2689d511aa97fa626b0d860c 100644 (file)
--- a/gcc/rtl.h
+++ b/gcc/rtl.h
@@ -2712,6 +2712,8 @@ extern int anti_dependence (const_rtx, const_rtx);
 extern int canon_anti_dependence (const_rtx, bool,
                                  const_rtx, enum machine_mode, rtx);
 extern int output_dependence (const_rtx, const_rtx);
+extern int canon_output_dependence (const_rtx, bool,
+                                   const_rtx, machine_mode, rtx);
 extern int may_alias_p (const_rtx, const_rtx);
 extern void init_alias_target (void);
 extern void init_alias_analysis (void);
index 9564581837da4641fb1265e0ed07f7429d817c8e..650afb05ed11a2d3d07d3f260a7017d7c7a36838 100644 (file)
@@ -1,3 +1,26 @@
+2016-07-07  Richard Biener  <rguenther@suse.de>
+
+       Backport from mainline
+       2016-04-04  Richard Biener  <rguenther@suse.de>
+
+       PR rtl-optimization/70484
+       * gcc.dg/torture/pr70484.c: New testcase.
+
+       2016-06-08  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/71452
+       * gcc.dg/torture/pr71452.c: New testcase.
+
+       2016-05-06  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/70931
+       * gfortran.dg/pr70931.f90: New testcase.
+
+       2016-03-01  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/70022
+       * gcc.dg/pr70022.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/pr70022.c b/gcc/testsuite/gcc.dg/pr70022.c
new file mode 100644 (file)
index 0000000..c7e60b8
--- /dev/null
@@ -0,0 +1,9 @@
+/* { dg-do compile } */
+
+typedef int v4si __attribute__ ((vector_size (16)));
+
+int
+foo (v4si v)
+{
+  return v[~0UL];
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr70484.c b/gcc/testsuite/gcc.dg/torture/pr70484.c
new file mode 100644 (file)
index 0000000..7604c65
--- /dev/null
@@ -0,0 +1,19 @@
+/* { dg-do run } */
+
+extern void abort (void);
+
+int __attribute__((noinline,noclone))
+f(int *pi, long *pl)
+{
+  *pi = 1;
+  *pl = 0;
+  return *(char *)pi;
+}
+
+int main()
+{
+  union { long l; int i; } a;
+  if (f (&a.i, &a.l) != 0)
+    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/gfortran.dg/pr70931.f90 b/gcc/testsuite/gfortran.dg/pr70931.f90
new file mode 100644 (file)
index 0000000..08ecd68
--- /dev/null
@@ -0,0 +1,10 @@
+! { dg-do compile }
+! { dg-options "-g" }
+program p
+   type t
+      integer :: a
+      integer :: b(0)
+   end type
+   type(t), parameter :: z = t(1, [2])
+   print *, z
+end
index 8ea1853fa89263ecb912945f517d089afe4bf234..3d3ffaa89820c1297a963f678d8472324694ccff 100644 (file)
@@ -1380,6 +1380,14 @@ 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)))))
          && (TREE_THIS_VOLATILE (decl) == TREE_THIS_VOLATILE (lhs)))
        return false;
     }