Bootstrapped and tested on x86_64-unknown-linux-gnu, applied.

Richard.

2018-11-06  Richard Biener  <rguent...@suse.de>

        PR tree-optimization/87889
        * tree-vect-loop-manip.c (slpeel_duplicate_current_defs_from_edges):
        Do nothing if old and new arg are the same

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

diff --git a/gcc/testsuite/gcc.dg/pr87894.c b/gcc/testsuite/gcc.dg/pr87894.c
new file mode 100644
index 00000000000..921a9cec468
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr87894.c
@@ -0,0 +1,26 @@
+/* { dg-do compile } */
+/* { dg-options "-Ofast" } */
+
+int a, b, c, d;
+double e;
+
+void f(double g[][1])
+{
+  for (;;)
+    {
+      double h;
+      for (; b < c; b++)
+       {
+         if (b >= 0)
+           ;
+         else if (d)
+           h = 2.0;
+         else
+           h = 0.0;
+         if (e)
+           g[a][b] = 0.0;
+         g[a][b] = h;
+       }
+    }
+}
+
diff --git a/gcc/tree-vect-loop-manip.c b/gcc/tree-vect-loop-manip.c
index f1b023b4e4e..d4e71b7195b 100644
--- a/gcc/tree-vect-loop-manip.c
+++ b/gcc/tree-vect-loop-manip.c
@@ -977,7 +977,8 @@ slpeel_duplicate_current_defs_from_edges (edge from, edge 
to)
        }
       if (TREE_CODE (from_arg) != SSA_NAME)
        gcc_assert (operand_equal_p (from_arg, to_arg, 0));
-      else if (TREE_CODE (to_arg) == SSA_NAME)
+      else if (TREE_CODE (to_arg) == SSA_NAME
+              && from_arg != to_arg)
        {
          if (get_current_def (to_arg) == NULL_TREE)
            {

Reply via email to