re PR tree-optimization/79621 (Missed path isolation opportunity)
authorJeff Law <law@redhat.com>
Tue, 21 Feb 2017 17:58:00 +0000 (10:58 -0700)
committerJeff Law <law@gcc.gnu.org>
Tue, 21 Feb 2017 17:58:00 +0000 (10:58 -0700)
PR tree-optimization/79621
* gimple-ssa-isolate-paths.c (find_implicit_erroneous_behavior): Ignore
blocks with edges to themselves.

PR tree-optimization/79621
* gcc.c-torture/compile/pr79621.c: New test.

From-SVN: r245637

gcc/ChangeLog
gcc/gimple-ssa-isolate-paths.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr79621.c [new file with mode: 0644]

index e265311109d2a66894b885c3f30282f723e5d85c..c0f554fed11ee3161f9ee04e21d77cfa41ce1b73 100644 (file)
@@ -1,3 +1,9 @@
+2017-02-21 Jeff Law  <law@redhat.com>
+
+       PR tree-optimization/79621
+       * gimple-ssa-isolate-paths.c (find_implicit_erroneous_behavior): Ignore
+       blocks with edges to themselves.
+
 2017-02-21  Jakub Jelinek  <jakub@redhat.com>
 
        PR target/79633
index 25e8c8aad4cf4fc83cdaa57b7fdaa6fcb4dbd85d..7babe0923625782e8d4e55681d92a2ee3154b234 100644 (file)
@@ -35,6 +35,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "tree-ssa.h"
 #include "cfgloop.h"
 #include "tree-cfg.h"
+#include "cfganal.h"
 #include "intl.h"
 
 
@@ -352,6 +353,16 @@ find_implicit_erroneous_behavior (void)
       if (has_abnormal_or_eh_outgoing_edge_p (bb))
        continue;
 
+
+      /* If BB has an edge to itself, then duplication of BB below
+        could result in reallocation of BB's PHI nodes.   If that happens
+        then the loop below over the PHIs would use the old PHI and
+        thus invalid information.  We don't have a good way to know
+        if a PHI has been reallocated, so just avoid isolation in
+        this case.  */
+      if (find_edge (bb, bb))
+       continue;
+
       /* First look for a PHI which sets a pointer to NULL and which
         is then dereferenced within BB.  This is somewhat overly
         conservative, but probably catches most of the interesting
index 9877624be83613ed4653e81113abc4c498125597..9f278bb8b8399daf4165443ff666afe64f81a8e3 100644 (file)
@@ -1,3 +1,8 @@
+2017-02-21  Jeff Law  <law@redhat.com>
+
+       PR tree-optimization/79621
+       * gcc.c-torture/compile/pr79621.c: New test.
+
 2017-02-21  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/79655
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr79621.c b/gcc/testsuite/gcc.c-torture/compile/pr79621.c
new file mode 100644 (file)
index 0000000..f115c07
--- /dev/null
@@ -0,0 +1,18 @@
+int b5;
+
+void
+h6 (int zb, int e7)
+{
+  while (b5 > 0)
+    {
+      int gv;
+
+      for (gv = 1; gv < 4; ++gv)
+        {
+          ((zb != 0) ? b5 : gv) && (b5 /= e7);
+          zb = 0;
+        }
+      e7 = 0;
+    }
+}
+