]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Backport PRs 91126, 91131, 91145, 91162, 91200
authorRichard Biener <rguenther@suse.de>
Wed, 31 Jul 2019 15:40:36 +0000 (15:40 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Wed, 31 Jul 2019 15:40:36 +0000 (15:40 +0000)
2019-07-31  Richard Biener  <rguenther@suse.de>

Backport from mainline
2019-07-19  Richard Biener  <rguenther@suse.de>

PR tree-optimization/91200
* tree-ssa-phiopt.c (cond_store_replacement): Check we have
no PHI nodes in middle-bb.

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

2019-07-15  Richard Biener  <rguenther@suse.de>

PR middle-end/91162
* tree-cfg.c (move_block_to_fn): When releasing a virtual PHI
node make sure to replace all uses with something valid.

* gcc.dg/autopar/pr91162.c: New testcase.

2019-07-12  Richard Biener  <rguenther@suse.de>

PR tree-optimization/91145
* tree-vect-slp.c (vect_build_slp_tree_2): Fix reduction
chain check.

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

2019-07-11  Richard Biener  <rguenther@suse.de>

PR middle-end/91131
* gimplify.c (gimplify_compound_literal_expr): Force a temporary
when the object is volatile and we have not cleared it even though
there are no nonzero elements.

* gcc.target/i386/pr91131.c: New testcase.

2019-07-10  Richard Biener  <rguenther@suse.de>

PR tree-optimization/91126
* tree-ssa-sccvn.c (n_walk_cb_data::push_partial_def): Adjust
native encoding offset for BYTES_BIG_ENDIAN.
(vn_reference_lookup_3): Likewise.

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

From-SVN: r273939

12 files changed:
gcc/ChangeLog
gcc/gimplify.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/autopar/pr91162.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/torture/pr91126.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/torture/pr91145.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/torture/pr91200.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/pr91131.c [new file with mode: 0644]
gcc/tree-cfg.c
gcc/tree-ssa-phiopt.c
gcc/tree-ssa-sccvn.c
gcc/tree-vect-slp.c

index 3bc840c518a38e9ca80dbe4f0183795281e90f8b..bd8fc676fddde6869a6f84e2abe95f63cf1d754d 100644 (file)
@@ -1,3 +1,38 @@
+2019-07-31  Richard Biener  <rguenther@suse.de>
+
+       Backport from mainline
+       2019-07-19  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/91200
+       * tree-ssa-phiopt.c (cond_store_replacement): Check we have
+       no PHI nodes in middle-bb.
+
+       2019-07-15  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/91162
+       * tree-cfg.c (move_block_to_fn): When releasing a virtual PHI
+       node make sure to replace all uses with something valid.
+
+       2019-07-12  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/91145
+       * tree-vect-slp.c (vect_build_slp_tree_2): Fix reduction
+       chain check.
+
+       2019-07-11  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/91131
+       * gimplify.c (gimplify_compound_literal_expr): Force a temporary
+       when the object is volatile and we have not cleared it even though
+       there are no nonzero elements.
+
+       2019-07-10  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/91126
+       * tree-ssa-sccvn.c (n_walk_cb_data::push_partial_def): Adjust
+       native encoding offset for BYTES_BIG_ENDIAN.
+       (vn_reference_lookup_3): Likewise.
+
 2019-07-30  Jan Hubicka  <jh@suse.cz>
 
        Backport from mainline
index f811221d33f797687514011209296c943592182f..a55242e90813ea4c05173a750673f001aa61418c 100644 (file)
@@ -4962,7 +4962,7 @@ gimplify_init_constructor (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p,
           one field to assign, initialize the target from a temporary.  */
        if (TREE_THIS_VOLATILE (object)
            && !TREE_ADDRESSABLE (type)
-           && num_nonzero_elements > 0
+           && (num_nonzero_elements > 0 || !cleared)
            && vec_safe_length (elts) > 1)
          {
            tree temp = create_tmp_var (TYPE_MAIN_VARIANT (type));
index 8765c2c442265e607e8ee8cbc4d132deaa17bd91..5e125672312b93466750a86f79d40e1f4405e03c 100644 (file)
@@ -1,3 +1,31 @@
+2019-07-31  Richard Biener  <rguenther@suse.de>
+
+       Backport from mainline
+       2019-07-19  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/91200
+       * gcc.dg/torture/pr91200.c: New testcase.
+
+       2019-07-15  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/91162
+       * gcc.dg/autopar/pr91162.c: New testcase.
+
+       2019-07-12  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/91145
+       * gcc.dg/torture/pr91145.c: New testcase.
+
+       2019-07-11  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/91131
+       * gcc.target/i386/pr91131.c: New testcase.
+
+       2019-07-10  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/91126
+       * gcc.dg/torture/pr91126.c: New testcase.
+
 2019-07-30  Steven G. Kargl  <kargl@gcc.gnu.org>
 
        PR fortran/91296
diff --git a/gcc/testsuite/gcc.dg/autopar/pr91162.c b/gcc/testsuite/gcc.dg/autopar/pr91162.c
new file mode 100644 (file)
index 0000000..ff243e4
--- /dev/null
@@ -0,0 +1,25 @@
+/* { dg-do compile { target int128 } } */
+/* { dg-options "-O -ftree-parallelize-loops=2 -fno-tree-dominator-opts --param parloops-min-per-thread=30" } */
+
+void
+zf (__int128 ct)
+{
+  __int128 *rk = &ct;
+
+  if (0)
+    {
+      int jj;
+
+t9:
+      for (jj = 0; jj < 60; ++jj)
+       {
+       }
+
+      __builtin_unreachable ();
+    }
+
+  while (*rk < 1)
+    ++*rk;
+
+  goto t9;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr91126.c b/gcc/testsuite/gcc.dg/torture/pr91126.c
new file mode 100644 (file)
index 0000000..8e34815
--- /dev/null
@@ -0,0 +1,28 @@
+/* { dg-do run } */
+
+struct S
+{
+  __INT32_TYPE__ a : 24;
+  __INT32_TYPE__ b : 8;
+} s;
+
+int
+main()
+{
+  s.a = 0xfefefe;
+  s.b = 0xfe;
+  unsigned char c;
+  c = ((unsigned char *)&s)[0];
+  if (c != 0xfe)
+    __builtin_abort ();
+  c = ((unsigned char *)&s)[1];
+  if (c != 0xfe)
+    __builtin_abort ();
+  c = ((unsigned char *)&s)[2];
+  if (c != 0xfe)
+    __builtin_abort ();
+  c = ((unsigned char *)&s)[3];
+  if (c != 0xfe)
+    __builtin_abort ();
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr91145.c b/gcc/testsuite/gcc.dg/torture/pr91145.c
new file mode 100644 (file)
index 0000000..7d62ad1
--- /dev/null
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-march=skylake-avx512" { target x86_64-*-* i?86-*-* } } */
+
+int a, c;
+unsigned b, e;
+extern unsigned d[100];
+
+void f()
+{
+  for (int g = 0; g < 70; g++)
+    {
+
+      b += d[g] - c;
+      e -= g ^ a;
+    }
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr91200.c b/gcc/testsuite/gcc.dg/torture/pr91200.c
new file mode 100644 (file)
index 0000000..09db9e1
--- /dev/null
@@ -0,0 +1,32 @@
+/* { dg-do compile } */
+
+int printf (const char *, ...);
+
+char a;
+int b, c, **d;
+
+int main ()
+{
+  int f = -128, *g, *h[2] = {0, 0}, i;
+  printf("0");
+  if (a)
+    {
+      while (f > a) {
+        int *j = &i;
+        *j |= 0;
+      }
+      h[i] = &c;
+    }
+  if (h[1])
+    {
+      int **k = &g;
+      *k = &f;
+      while (i)
+        {
+          int **l[] = {&g};
+        }
+      int **m = &g;
+      *d = *m = &b;
+    }
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.target/i386/pr91131.c b/gcc/testsuite/gcc.target/i386/pr91131.c
new file mode 100644 (file)
index 0000000..85008ff
--- /dev/null
@@ -0,0 +1,19 @@
+/* { dg-do compile } */
+/* { dg-options "-O" } */
+
+struct Reg_T {
+    unsigned int a : 3;
+    unsigned int b : 1;
+    unsigned int c : 4;
+};
+
+volatile struct Reg_T Reg_A;
+
+int
+main ()
+{
+  Reg_A = (struct Reg_T){ .a = 0, .b = 0, .c = 0 };
+  return 0;
+}
+
+/* { dg-final { scan-assembler-times "mov\[^\r\n\]*Reg_A" 1 } } */
index 587408150fb0e9ff9a7a9a6ccaa321b16c7ccecc..32be59acfb06cbc285a01326ce34009eb9b9151b 100644 (file)
@@ -7040,7 +7040,14 @@ move_block_to_fn (struct function *dest_cfun, basic_block bb,
       if (virtual_operand_p (op))
        {
          /* Remove the phi nodes for virtual operands (alias analysis will be
-            run for the new function, anyway).  */
+            run for the new function, anyway).  But replace all uses that
+            might be outside of the region we move.  */
+         use_operand_p use_p;
+         imm_use_iterator iter;
+         gimple *use_stmt;
+         FOR_EACH_IMM_USE_STMT (use_stmt, iter, op)
+           FOR_EACH_IMM_USE_ON_STMT (use_p, iter)
+             SET_USE (use_p, SSA_NAME_VAR (op));
           remove_phi_node (&psi, true);
          continue;
        }
index 90674a2f3c49a852b208daf032b2934c343c45be..8bf09bdf2a0c1acdcd601dd63fa17abaa179f46e 100644 (file)
@@ -2198,6 +2198,11 @@ cond_store_replacement (basic_block middle_bb, basic_block join_bb,
       || gimple_has_volatile_ops (assign))
     return false;
 
+  /* And no PHI nodes so all uses in the single stmt are also
+     available where we insert to.  */
+  if (!gimple_seq_empty_p (phi_nodes (middle_bb)))
+    return false;
+
   locus = gimple_location (assign);
   lhs = gimple_assign_lhs (assign);
   rhs = gimple_assign_rhs1 (assign);
index cd9448138295c5fbb26bcf7c64ee297735f26a7c..8bc2a9da6c820d4ccfa7cd44cdeb6fbe67c8d1a6 100644 (file)
@@ -2238,9 +2238,20 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *vr_,
          tree rhs = gimple_assign_rhs1 (def_stmt);
          if (TREE_CODE (rhs) == SSA_NAME)
            rhs = SSA_VAL (rhs);
-         len = native_encode_expr (gimple_assign_rhs1 (def_stmt),
+         unsigned pad = 0;
+         if (BYTES_BIG_ENDIAN
+             && is_a <scalar_mode> (TYPE_MODE (TREE_TYPE (rhs))))
+           {
+             /* On big-endian the padding is at the 'front' so
+                just skip the initial bytes.  */
+             fixed_size_mode mode
+                 = as_a <fixed_size_mode> (TYPE_MODE (TREE_TYPE (rhs)));
+             pad = GET_MODE_SIZE (mode) - size2 / BITS_PER_UNIT;
+           }
+         len = native_encode_expr (rhs,
                                    buffer, sizeof (buffer),
-                                   (offseti - offset2) / BITS_PER_UNIT);
+                                   ((offseti - offset2) / BITS_PER_UNIT
+                                    + pad));
          if (len > 0 && len * BITS_PER_UNIT >= maxsizei)
            {
              tree type = vr->type;
index 40db1a208f114c22964dfb4ebfd27c03cecfbcaa..c3137460fd14569416f36b637c3216792b614b71 100644 (file)
@@ -1126,7 +1126,8 @@ vect_build_slp_tree_2 (vec_info *vinfo,
          FOR_EACH_VEC_ELT (stmts, i, other_info)
            {
              /* But for reduction chains only check on the first stmt.  */
-             if (REDUC_GROUP_FIRST_ELEMENT (other_info)
+             if (!STMT_VINFO_DATA_REF (other_info)
+                 && REDUC_GROUP_FIRST_ELEMENT (other_info)
                  && REDUC_GROUP_FIRST_ELEMENT (other_info) != stmt_info)
                continue;
              if (STMT_VINFO_DEF_TYPE (other_info) != def_type)