]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: [multiple changes]
authorRichard Biener <rguenther@suse.de>
Tue, 26 Mar 2019 13:18:23 +0000 (13:18 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 26 Mar 2019 13:18:23 +0000 (13:18 +0000)
2019-02-26  Richard Biener  <rguenther@suse.de>

Backport from mainline
2019-02-12  Richard Biener  <rguenther@suse.de>

PR tree-optimization/89253
* tree-ssa-loop-split.c (tree_ssa_split_loops): Check we can
duplicate the loop.

* gfortran.dg/pr89253.f: New testcase.

2019-02-08  Richard Biener  <rguenther@suse.de>

PR middle-end/89223
* tree-data-ref.c (initialize_matrix_A): Fail if constant
doesn't fit in HWI.
(analyze_subscript_affine_affine): Handle failure from
initialize_matrix_A.

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

2019-01-28  Richard Biener  <rguenther@suse.de>

PR tree-optimization/88739
* tree-ssa-sccvn.c (vn_reference_lookup_3): Avoid generating
BIT_FIELD_REFs of non-mode-precision integral operands.

* gcc.c-torture/execute/pr88739.c: New test.

From-SVN: r269942

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/pr88739.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/torture/pr89223.c [new file with mode: 0644]
gcc/testsuite/gfortran.dg/pr89253.f [new file with mode: 0644]
gcc/tree-data-ref.c
gcc/tree-ssa-loop-split.c
gcc/tree-ssa-sccvn.c

index 58cd084a47d923d74c0248c3fb538ead4a78d2b4..b81f2fd027a2337cc9531292bde85be15f7af044 100644 (file)
@@ -1,3 +1,26 @@
+2019-02-26  Richard Biener  <rguenther@suse.de>
+
+       Backport from mainline
+       2019-02-12  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/89253
+       * tree-ssa-loop-split.c (tree_ssa_split_loops): Check we can
+       duplicate the loop.
+
+       2019-02-08  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/89223
+       * tree-data-ref.c (initialize_matrix_A): Fail if constant
+       doesn't fit in HWI.
+       (analyze_subscript_affine_affine): Handle failure from
+       initialize_matrix_A.
+
+       2019-01-28  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/88739
+       * tree-ssa-sccvn.c (vn_reference_lookup_3): Avoid generating
+       BIT_FIELD_REFs of non-mode-precision integral operands.
+
 2019-03-26  Richard Biener  <rguenther@suse.de>
 
        Backport from mainline
index 242c721bc982720fcdd8dba0a3b29617329fce6a..cdcb617ca6a67606e42afdb8151d1f7226032b2e 100644 (file)
@@ -1,3 +1,21 @@
+2019-02-26  Richard Biener  <rguenther@suse.de>
+
+       Backport from mainline
+       2019-02-12  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/89253
+       * gfortran.dg/pr89253.f: New testcase.
+
+       2019-02-08  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/89223
+       * gcc.dg/torture/pr89223.c: New testcase.
+
+       2019-01-28  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/88739
+       * gcc.c-torture/execute/pr88739.c: New test.
+
 2019-03-26  Richard Biener  <rguenther@suse.de>
 
        Backport from mainline
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr88739.c b/gcc/testsuite/gcc.c-torture/execute/pr88739.c
new file mode 100644 (file)
index 0000000..d4b32fb
--- /dev/null
@@ -0,0 +1,59 @@
+/* PR tree-optimization/88739 */
+#if __SIZEOF_SHORT__ == 2 &&  __SIZEOF_INT__ == 4 && __CHAR_BIT__ == 8
+struct A
+{
+  unsigned int a, b, c;
+  unsigned int d : 30;
+  unsigned int e : 2;
+};
+
+union U
+{
+  struct A f;
+  unsigned int g[4];
+  unsigned short h[8];
+  unsigned char i[16];
+};
+volatile union U v = { .f.d = 0x4089 };
+
+__attribute__((noipa)) void
+bar (int x)
+{
+  static int i;
+  switch (i++)
+    {
+    case 0: if (x != v.f.d) __builtin_abort (); break;
+    case 1: if (x != v.f.e) __builtin_abort (); break;
+    case 2: if (x != v.g[3]) __builtin_abort (); break;
+    case 3: if (x != v.h[6]) __builtin_abort (); break;
+    case 4: if (x != v.h[7]) __builtin_abort (); break;
+    default: __builtin_abort (); break;
+    }
+}
+
+void
+foo (unsigned int x)
+{
+  union U u;
+  u.f.d = x >> 2;
+  u.f.e = 0;
+  bar (u.f.d);
+  bar (u.f.e);
+  bar (u.g[3]);
+  bar (u.h[6]);
+  bar (u.h[7]);
+}
+
+int
+main ()
+{
+  foo (0x10224);
+  return 0;
+}
+#else
+int
+main ()
+{
+  return 0;
+}
+#endif
diff --git a/gcc/testsuite/gcc.dg/torture/pr89223.c b/gcc/testsuite/gcc.dg/torture/pr89223.c
new file mode 100644 (file)
index 0000000..1e82811
--- /dev/null
@@ -0,0 +1,10 @@
+/* { dg-do compile { target int128 } } */
+
+int a[5];
+unsigned __int128 b;
+void c()
+{
+  b = 4;
+  for (;; b--)
+    a[b] = ({ a[b + b]; });
+}
diff --git a/gcc/testsuite/gfortran.dg/pr89253.f b/gcc/testsuite/gfortran.dg/pr89253.f
new file mode 100644 (file)
index 0000000..6dc9df1
--- /dev/null
@@ -0,0 +1,19 @@
+! { dg-do compile }
+! { dg-additional-options "-fsplit-loops -fno-tree-dominator-opts -std=legacy -w" }
+      program jr
+      integer :: w5, pg, zh
+      w5 = 0
+      write (w5)
+      assign 0002 to w5
+      do pg = 1, 3
+         if (pg .eq. 1) then
+            do zh = 1, pg
+            end do
+         else
+            goto w5
+ 0001       zh = 0
+ 0002       zh = 0
+            assign 0001 to w5
+         endif
+      end do
+      end
index 2480f4e55617faa4b020dccb8b0367d09a8117e8..a349e3ec5f12731f9b9618baecd99728cfaa623b 100644 (file)
@@ -2118,6 +2118,8 @@ initialize_matrix_A (lambda_matrix A, tree chrec, unsigned index, int mult)
   switch (TREE_CODE (chrec))
     {
     case POLYNOMIAL_CHREC:
+      if (!cst_and_fits_in_hwi (CHREC_RIGHT (chrec)))
+       return chrec_dont_know;
       A[index][0] = mult * int_cst_value (CHREC_RIGHT (chrec));
       return initialize_matrix_A (A, CHREC_LEFT (chrec), index + 1, mult);
 
@@ -2499,7 +2501,7 @@ analyze_subscript_affine_affine (tree chrec_a,
                                 tree *last_conflicts)
 {
   unsigned nb_vars_a, nb_vars_b, dim;
-  HOST_WIDE_INT init_a, init_b, gamma, gcd_alpha_beta;
+  HOST_WIDE_INT gamma, gcd_alpha_beta;
   lambda_matrix A, U, S;
   struct obstack scratch_obstack;
 
@@ -2536,9 +2538,20 @@ analyze_subscript_affine_affine (tree chrec_a,
   A = lambda_matrix_new (dim, 1, &scratch_obstack);
   S = lambda_matrix_new (dim, 1, &scratch_obstack);
 
-  init_a = int_cst_value (initialize_matrix_A (A, chrec_a, 0, 1));
-  init_b = int_cst_value (initialize_matrix_A (A, chrec_b, nb_vars_a, -1));
-  gamma = init_b - init_a;
+  tree init_a = initialize_matrix_A (A, chrec_a, 0, 1);
+  tree init_b = initialize_matrix_A (A, chrec_b, nb_vars_a, -1);
+  if (init_a == chrec_dont_know
+      || init_b == chrec_dont_know)
+    {
+      if (dump_file && (dump_flags & TDF_DETAILS))
+       fprintf (dump_file, "affine-affine test failed: "
+                "representation issue.\n");
+      *overlaps_a = conflict_fn_not_known ();
+      *overlaps_b = conflict_fn_not_known ();
+      *last_conflicts = chrec_dont_know;
+      goto end_analyze_subs_aa;
+    }
+  gamma = int_cst_value (init_b) - int_cst_value (init_a);
 
   /* Don't do all the hard work of solving the Diophantine equation
      when we already know the solution: for example,
index fd97213774950077a6d436568f679f04c04962b7..3992597e241114ea7ea074485f542e69d85bf78f 100644 (file)
@@ -649,7 +649,8 @@ tree_ssa_split_loops (void)
                                        false, true)
          && niter.cmp != ERROR_MARK
          /* We can't yet handle loops controlled by a != predicate.  */
-         && niter.cmp != NE_EXPR)
+         && niter.cmp != NE_EXPR
+         && can_duplicate_loop_p (loop))
        {
          if (split_loop (loop, &niter))
            {
index c93f1f2619591cee775926e831183b3b7ab72124..a2e3ce26dcbc6df33e252006a88a3bf8a8a461d9 100644 (file)
@@ -2029,6 +2029,7 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *vr_,
       base2 = get_ref_base_and_extent (gimple_assign_lhs (def_stmt),
                                       &offset2, &size2, &maxsize2,
                                       &reverse);
+      tree def_rhs = gimple_assign_rhs1 (def_stmt);
       if (!reverse
          && maxsize2 != -1
          && maxsize2 == size2
@@ -2041,11 +2042,14 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *vr_,
             according to endianness.  */
          && (! INTEGRAL_TYPE_P (vr->type)
              || ref->size == TYPE_PRECISION (vr->type))
-         && ref->size % BITS_PER_UNIT == 0)
+         && ref->size % BITS_PER_UNIT == 0
+         && (! INTEGRAL_TYPE_P (TREE_TYPE (def_rhs))
+             || (TYPE_PRECISION (TREE_TYPE (def_rhs))
+                 == GET_MODE_PRECISION (TYPE_MODE (TREE_TYPE (def_rhs))))))
        {
          code_helper rcode = BIT_FIELD_REF;
          tree ops[3];
-         ops[0] = SSA_VAL (gimple_assign_rhs1 (def_stmt));
+         ops[0] = SSA_VAL (def_rhs);
          ops[1] = bitsize_int (ref->size);
          ops[2] = bitsize_int (offset - offset2);
          tree val = vn_nary_build_or_lookup (rcode, vr->type, ops);