]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Backport PRs 59817, 60453, 60750, 60836, 60895
authorRichard Biener <rguenther@suse.de>
Mon, 5 May 2014 13:48:42 +0000 (13:48 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 5 May 2014 13:48:42 +0000 (13:48 +0000)
2014-05-05  Richard Biener  <rguenther@suse.de>

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

PR middle-end/60895
* tree-inline.c (declare_return_variable): Use mark_addressable.

* g++.dg/torture/pr60895.C: New testcase.

2014-04-07  Richard Biener  <rguenther@suse.de>

PR middle-end/60750
* tree-ssa-operands.c (maybe_add_call_vops): Also add VDEFs
for noreturn calls.
* tree-cfgcleanup.c (fixup_noreturn_call): Do not remove VDEFs.

* g++.dg/torture/pr60750.C: New testcase.
* gcc.dg/tree-ssa/20040517-1.c: Adjust.

2014-04-14  Richard Biener  <rguenther@suse.de>

PR tree-optimization/59817
PR tree-optimization/60453
* graphite-scop-detection.c (graphite_can_represent_scev): Complete
recursion to catch all CHRECs in the scalar evolution and restrict
the predicate for the remains appropriately.

* gfortran.dg/graphite/pr59817.f: New testcase.
* gcc.dg/graphite/pr59817-1.c: Likewise.
* gcc.dg/graphite/pr59817-2.c: Likewise.

2014-04-17  Richard Biener  <rguenther@suse.de>

PR tree-optimization/60836
* tree-vect-loop.c (vect_create_epilog_for_reduction): Force
initial PHI args to be gimple values.

* g++.dg/vect/pr60836.cc: New testcase.

From-SVN: r210070

14 files changed:
gcc/ChangeLog
gcc/graphite-scop-detection.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/torture/pr60750.C [new file with mode: 0644]
gcc/testsuite/g++.dg/torture/pr60895.C [new file with mode: 0644]
gcc/testsuite/g++.dg/vect/pr60836.cc [new file with mode: 0644]
gcc/testsuite/gcc.dg/graphite/pr59817-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/graphite/pr59817-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-ssa/20040517-1.c
gcc/testsuite/gfortran.dg/graphite/pr59817.f [new file with mode: 0644]
gcc/tree-cfgcleanup.c
gcc/tree-inline.c
gcc/tree-ssa-operands.c
gcc/tree-vect-loop.c

index f4de0bcd86c274f00cbd5c092bfc69b5627b2d8d..1058b8fb0051b1f1702f43df5a183de20ce69e2c 100644 (file)
@@ -1,3 +1,32 @@
+2014-05-05  Richard Biener  <rguenther@suse.de>
+
+       Backport from mainline
+       2014-04-23  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/60895
+       * tree-inline.c (declare_return_variable): Use mark_addressable.
+
+       2014-04-07  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/60750
+       * tree-ssa-operands.c (maybe_add_call_vops): Also add VDEFs
+       for noreturn calls.
+       * tree-cfgcleanup.c (fixup_noreturn_call): Do not remove VDEFs.
+
+       2014-04-14  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/59817
+       PR tree-optimization/60453
+       * graphite-scop-detection.c (graphite_can_represent_scev): Complete
+       recursion to catch all CHRECs in the scalar evolution and restrict
+       the predicate for the remains appropriately.
+
+       2014-04-17  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/60836
+       * tree-vect-loop.c (vect_create_epilog_for_reduction): Force
+       initial PHI args to be gimple values.
+
 2014-05-05  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
index bd0ec8928325f225e2ecb20d7279db1866fb6fba..e0d8f7cec7ddfd96c8f2ac822986ec2d9d542cad 100644 (file)
@@ -203,7 +203,14 @@ graphite_can_represent_scev (tree scev)
 
   switch (TREE_CODE (scev))
     {
+    case NEGATE_EXPR:
+    case BIT_NOT_EXPR:
+    CASE_CONVERT:
+    case NON_LVALUE_EXPR:
+      return graphite_can_represent_scev (TREE_OPERAND (scev, 0));
+
     case PLUS_EXPR:
+    case POINTER_PLUS_EXPR:
     case MINUS_EXPR:
       return graphite_can_represent_scev (TREE_OPERAND (scev, 0))
        && graphite_can_represent_scev (TREE_OPERAND (scev, 1));
@@ -225,13 +232,15 @@ graphite_can_represent_scev (tree scev)
       if (!evolution_function_right_is_integer_cst (scev)
          || !graphite_can_represent_init (scev))
        return false;
+      return graphite_can_represent_scev (CHREC_LEFT (scev));
 
     default:
       break;
     }
 
   /* Only affine functions can be represented.  */
-  if (!scev_is_linear_expression (scev))
+  if (tree_contains_chrecs (scev, NULL)
+      || !scev_is_linear_expression (scev))
     return false;
 
   return true;
index 8cb497d966e178d8afee1a11b40767a433297638..ab19c0851ffaa9efcb82e3c72f9f506c47947788 100644 (file)
@@ -1,3 +1,30 @@
+2014-05-05  Richard Biener  <rguenther@suse.de>
+
+       Backport from mainline
+       2014-04-23  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/60895
+       * g++.dg/torture/pr60895.C: New testcase.
+
+       2014-04-07  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/60750
+       * g++.dg/torture/pr60750.C: New testcase.
+       * gcc.dg/tree-ssa/20040517-1.c: Adjust.
+
+       2014-04-14  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/59817
+       PR tree-optimization/60453
+       * gfortran.dg/graphite/pr59817.f: New testcase.
+       * gcc.dg/graphite/pr59817-1.c: Likewise.
+       * gcc.dg/graphite/pr59817-2.c: Likewise.
+
+       2014-04-17  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/60836
+       * g++.dg/vect/pr60836.cc: New testcase.
+
 2014-05-05  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
diff --git a/gcc/testsuite/g++.dg/torture/pr60750.C b/gcc/testsuite/g++.dg/torture/pr60750.C
new file mode 100644 (file)
index 0000000..a344bd7
--- /dev/null
@@ -0,0 +1,21 @@
+// { dg-do run }
+// { dg-options "-std=c++11" }
+
+#include <string>
+#include <stdexcept>
+
+const std::string err_prefix = "Problem: ";
+void thrower (std::string msg)
+{
+  throw std::runtime_error(err_prefix + std::move(msg));
+}
+
+int main(int argc, char **argv)
+{
+  try {
+      std::string base = "hello";
+      thrower(std::move(base));
+  } catch (const std::runtime_error &e) {
+  }
+  return 0;
+}
diff --git a/gcc/testsuite/g++.dg/torture/pr60895.C b/gcc/testsuite/g++.dg/torture/pr60895.C
new file mode 100644 (file)
index 0000000..0edd36a
--- /dev/null
@@ -0,0 +1,32 @@
+// { dg-do compile }
+
+struct C
+{
+  double elems[3];
+};
+
+C
+foo ()
+{
+  C a;
+  double *f = a.elems;
+  int b;
+  for (; b;)
+    {
+      *f = 0;
+      ++f;
+    }
+  return a;
+}
+
+struct J
+{
+  C c;
+  __attribute__((always_inline)) J () : c (foo ()) {}
+};
+
+void
+bar ()
+{
+  J ();
+}
diff --git a/gcc/testsuite/g++.dg/vect/pr60836.cc b/gcc/testsuite/g++.dg/vect/pr60836.cc
new file mode 100644 (file)
index 0000000..83bb183
--- /dev/null
@@ -0,0 +1,39 @@
+// { dg-do compile }
+
+int a, b;
+typedef double (*NormFunc) (const int &);
+int &
+max (int &p1, int &p2)
+{
+  if (p1 < p2)
+    return p2;
+  return p1;
+}
+
+struct A
+{
+  int operator      () (int p1, int p2)
+    {
+      return max (p1, p2);
+    }
+};
+template < class, class > double
+norm_ (const int &)
+{
+  char c, d;
+  A e;
+  for (; a; a++)
+    {
+      b = e (b, d);
+      b = e (b, c);
+    }
+}
+
+void
+norm ()
+{
+  static NormFunc f = norm_ < int, A >;
+  f = 0;
+}
+
+// { dg-final { cleanup-tree-dump "vect" } }
diff --git a/gcc/testsuite/gcc.dg/graphite/pr59817-1.c b/gcc/testsuite/gcc.dg/graphite/pr59817-1.c
new file mode 100644 (file)
index 0000000..175fa16
--- /dev/null
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -floop-interchange" } */
+
+int kd;
+
+void
+n2(void)
+{
+  static int so;
+  static short int i5;
+  int wj;
+  int *il;
+  int *nk = &so;
+  for (wj = 0; wj < 2; ++wj)
+    *nk = ((i5 += *il) || kd );
+}
diff --git a/gcc/testsuite/gcc.dg/graphite/pr59817-2.c b/gcc/testsuite/gcc.dg/graphite/pr59817-2.c
new file mode 100644 (file)
index 0000000..1395007
--- /dev/null
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -floop-interchange" } */
+
+void
+xl(void)
+{
+  static int j3;
+  for (j3 = 0; j3 < 1; ++j3) {
+      static int f2;
+      static int w7;
+      short int b5;
+      int ok;
+      f2 = (b5 += ok) ? (w7 = 0): (w7 ? 0 : (f2 = ok));
+  }
+}
index 99b27ce02f1a9c35dba6e58fcd5b5d33204f665b..b49cf648c7d1fa6cb0fcaf370756a168caa8dcd7 100644 (file)
@@ -16,6 +16,7 @@ void bar (void)
 /* We used to treat malloc functions like pure and const functions, but
    malloc functions may clobber global memory.  Only the function result
    does not alias any other pointer.
-   Hence, we must have a VDEF for a before and after the call to foo().  */
-/* { dg-final { scan-tree-dump-times "VDEF" 2 "alias"} } */
+   Hence, we must have a VDEF for a before and after the call to foo().
+   And one after the call to abort().  */
+/* { dg-final { scan-tree-dump-times "VDEF" 3 "alias"} } */
 /* { dg-final { cleanup-tree-dump "alias" } } */
diff --git a/gcc/testsuite/gfortran.dg/graphite/pr59817.f b/gcc/testsuite/gfortran.dg/graphite/pr59817.f
new file mode 100644 (file)
index 0000000..a9ee8f1
--- /dev/null
@@ -0,0 +1,14 @@
+! { dg-do compile }
+! { dg-options "-O2 -floop-interchange" }
+      SUBROUTINE PREPD(ICAST,ICAS,ICASX,ICAS1,ICAS2,NDET,NM,III,IMP,
+     *                 CASMIN)
+      LOGICAL CASMIN
+      DIMENSION ICAST(NDET,NM),IMP(NM)
+      IF(CASMIN) THEN
+         DO K=1,NDET
+            DO L=1,NM
+               IF(L.EQ.K-1) ICAST(K,L) = 1
+            END DO
+         END DO
+      END IF
+      END SUBROUTINE
index 064d994ad3da27ee72b03e39363d98b68c7b7495..aeb5e4e8cfbe9df565c36dd898700411f2397783 100644 (file)
@@ -539,9 +539,6 @@ fixup_noreturn_call (gimple stmt)
       update_stmt (stmt);
       changed = true;
     }
-  /* Similarly remove VDEF if there is any.  */
-  else if (gimple_vdef (stmt))
-    update_stmt (stmt);
   return changed;
 }
 
index 5121765fd35bcfaceb5ec0ef621b1b826092189f..d2dfc438a9a3cf09c8ea011727db7a258357a771 100644 (file)
@@ -2841,7 +2841,8 @@ declare_return_variable (copy_body_data *id, tree return_slot, tree modify_dest,
        {
          var = return_slot;
          gcc_assert (TREE_CODE (var) != SSA_NAME);
-         TREE_ADDRESSABLE (var) |= TREE_ADDRESSABLE (result);
+         if (TREE_ADDRESSABLE (result))
+           mark_addressable (var);
        }
       if ((TREE_CODE (TREE_TYPE (result)) == COMPLEX_TYPE
            || TREE_CODE (TREE_TYPE (result)) == VECTOR_TYPE)
index 0915080c71cdc2a2d67f1afb160014df5f94ff9f..a4ddb6e817f89874b72ca8989b4e3a841fa7a217 100644 (file)
@@ -626,10 +626,8 @@ maybe_add_call_vops (gimple stmt)
      call-clobbered.  */
   if (!(call_flags & ECF_NOVOPS))
     {
-      /* A 'pure' or a 'const' function never call-clobbers anything.
-        A 'noreturn' function might, but since we don't return anyway
-        there is no point in recording that.  */
-      if (!(call_flags & (ECF_PURE | ECF_CONST | ECF_NORETURN)))
+      /* A 'pure' or a 'const' function never call-clobbers anything.  */
+      if (!(call_flags & (ECF_PURE | ECF_CONST)))
        add_virtual_operand (stmt, opf_def);
       else if (!(call_flags & ECF_CONST))
        add_virtual_operand (stmt, opf_use);
index 8495287db671bf39d12421f260d0d0cd69c29672..7607d956d9ef29adc9cfad4d6e7315806818c7c6 100644 (file)
@@ -3791,8 +3791,12 @@ vect_create_epilog_for_reduction (vec<tree> vect_defs, gimple stmt,
   /* Set phi nodes arguments.  */
   FOR_EACH_VEC_ELT (reduction_phis, i, phi)
     {
-      tree vec_init_def = vec_initial_defs[i];
-      tree def = vect_defs[i];
+      tree vec_init_def, def;
+      gimple_seq stmts;
+      vec_init_def = force_gimple_operand (vec_initial_defs[i], &stmts,
+                                          true, NULL_TREE);
+      gsi_insert_seq_on_edge_immediate (loop_preheader_edge (loop), stmts);
+      def = vect_defs[i];
       for (j = 0; j < ncopies; j++)
         {
           /* Set the loop-entry arg of the reduction-phi.  */