re PR tree-optimization/71039 (ICE: verify_ssa failed (error: definition in block...
authorRichard Biener <rguenther@suse.de>
Tue, 10 May 2016 13:13:59 +0000 (13:13 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 10 May 2016 13:13:59 +0000 (13:13 +0000)
2016-05-10  Richard Biener  <rguenther@suse.de>

PR tree-optimization/71039
* tree-ssa-phiprop.c: Include tree-ssa-loop.h.
(chk_uses): New function.
(propagate_with_phi): Verify we can safely replicate the lhs of an
aggregate assignment on all incoming edges.

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

From-SVN: r236079

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr71039.c [new file with mode: 0644]
gcc/tree-ssa-phiprop.c

index fa23868f340d00d071b19aba116f0c69b0c98b6d..fa3473d88cb1584eeec51b396cebe84e20586027 100644 (file)
@@ -1,3 +1,11 @@
+2016-05-10  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/71039
+       * tree-ssa-phiprop.c: Include tree-ssa-loop.h.
+       (chk_uses): New function.
+       (propagate_with_phi): Verify we can safely replicate the lhs of an
+       aggregate assignment on all incoming edges.
+
 2016-05-10  Oleg Endo  <olegendo@gcc.gnu.org>
 
        * config/rx/rx-protos.h (is_interrupt_func, is_fast_interrupt_func):
index c4367b8b6091970b3c14461ac554a4dcad1b90c4..1ab0fce238acf702cd193063e2a1ffb31006c170 100644 (file)
@@ -1,3 +1,8 @@
+2016-05-10  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/71039
+       * gcc.dg/torture/pr71039.c: New testcase.
+
 2016-05-10  Nathan Sidwell  <nathan@acm.org>
 
        * gcc.dg/nested-func-10.c: Requires alloca.
diff --git a/gcc/testsuite/gcc.dg/torture/pr71039.c b/gcc/testsuite/gcc.dg/torture/pr71039.c
new file mode 100644 (file)
index 0000000..e169bdc
--- /dev/null
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+
+struct wv
+{
+  int qi;
+} qp, *ft;
+void *pb;
+
+void
+wz (void)
+{
+  struct wv *vf = pb ? (struct wv *)&pb : &qp;
+  *ft = *vf;
+}
index 80d2fc4cf45f6cbf526c284981443926133440a3..20fda6cb714815252fcaf47583a8ebfc62c7cee6 100644 (file)
@@ -32,6 +32,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "gimplify.h"
 #include "gimple-iterator.h"
 #include "stor-layout.h"
+#include "tree-ssa-loop.h"
 
 /* This pass propagates indirect loads through the PHI node for its
    address to make the load source possibly non-addressable and to
@@ -230,6 +231,19 @@ phiprop_insert_phi (basic_block bb, gphi *phi, gimple *use_stmt,
   return res;
 }
 
+/* Verify if *idx is available at *DATA.  */
+
+static bool
+chk_uses (tree, tree *idx, void *data)
+{
+  basic_block dom = (basic_block) data;
+  if (TREE_CODE (*idx) == SSA_NAME)
+    return (SSA_NAME_IS_DEFAULT_DEF (*idx)
+           || ! dominated_by_p (CDI_DOMINATORS,
+                                gimple_bb (SSA_NAME_DEF_STMT (*idx)), dom));
+  return true;
+}
+
 /* Propagate between the phi node arguments of PHI in BB and phi result
    users.  For now this matches
         # p_2 = PHI <&x, &y>
@@ -342,6 +356,13 @@ propagate_with_phi (basic_block bb, gphi *phi, struct phiprop_d *phivn,
          insert aggregate copies on the edges instead.  */
       if (!is_gimple_reg_type (TREE_TYPE (TREE_TYPE (ptr))))
        {
+         /* As we replicate the lhs on each incoming edge all
+            used SSA names have to be available there.  */
+         if (! for_each_index (gimple_assign_lhs_ptr (use_stmt),
+                               chk_uses,
+                               get_immediate_dominator (CDI_DOMINATORS,
+                                                        gimple_bb (phi))))
+           goto next;
          phiprop_insert_phi (bb, phi, use_stmt, phivn, n);
 
          /* Remove old stmt.  The phi is taken care of by DCE.  */