re PR tree-optimization/33920 (Segfault in combine_blocks/tree-if-conv.c)
authorUros Bizjak <uros@gcc.gnu.org>
Sun, 28 Oct 2007 14:57:50 +0000 (15:57 +0100)
committerUros Bizjak <uros@gcc.gnu.org>
Sun, 28 Oct 2007 14:57:50 +0000 (15:57 +0100)
        PR tree-optimization/33920
        * tree-if-conv.c (tree_if_conversion): Force predicate of single
        successor bb to true when predecessor bb has NULL predicate.
        (find_phi_replacement_condition): Assert that tmp_cond is non-null.

testsuite/ChangeLog:

        PR tree-optimization/33920
        * gcc.dg/tree-ssa/pr33290.c: New test.

From-SVN: r129696

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/pr33920.c [new file with mode: 0644]
gcc/tree-if-conv.c

index 9e772d65055106363c42079cb04162ad40208168..7ec6c5710e3ee65b0808c3d1e082f79c71f073c7 100644 (file)
@@ -1,3 +1,10 @@
+2007-10-28  Uros Bizjak  <ubizjak@gmail.com>
+
+       PR tree-optimization/33920
+       * tree-if-conv.c (tree_if_conversion): Force predicate of single
+       successor bb to true when predecessor bb has NULL predicate.
+       (find_phi_replacement_condition): Assert that tmp_cond is non-null.
+
 2007-10-28  Richard Sandiford  <rsandifo@nildram.co.uk>
 
        * config/mips/mips.md: Add combiner patterns for DImode extensions
index d47b1087a997877891548f6f7cb4862063cfe88a..2988c0c378d364467c19324b57dadf96d5d5a16e 100644 (file)
@@ -1,3 +1,9 @@
+2007-10-28  Martin Michlmayr  <tbm@cyrius.com>
+           Uros Bizjak  <ubizjak@gmail.com>
+
+       PR tree-optimization/33920
+       * gcc.dg/tree-ssa/pr33290.c: New test.
+
 2007-10-27 Jerry DeLisle <jvdelisle@gcc.gnu.org>
 
        PR fortran/31306
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr33920.c b/gcc/testsuite/gcc.dg/tree-ssa/pr33920.c
new file mode 100644 (file)
index 0000000..1cece81
--- /dev/null
@@ -0,0 +1,51 @@
+/* Testcase by Martin Michlmayr <tbm@cyrius.com> */
+/* { dg-do compile } */
+/* { dg-options "-O3" } */
+
+typedef union lispunion *object;
+struct character
+{
+  long e;
+};
+extern struct symbol Cnil_body;
+extern struct symbol Ct_body;
+struct vector
+{
+  object *v_self;
+};
+union lispunion
+{
+  struct vector v;
+};
+void init_code ()
+{
+  object V659;
+  object _x, _y;
+  object V643;
+  long V648;
+  unsigned char V653;
+  object V651;
+  object V654;
+  object V658;
+
+T1240:
+  if (V648 >= (long)V651)
+    goto T1243;
+  V653 = ((char *) V654->v.v_self)[V648];
+  V659 = (object) V654 + V653;
+T1261:
+  V658 =
+    (object)
+     V659 ? (object) & Ct_body : (object) & Cnil_body;
+  if (V658 == (object) & Cnil_body)
+    goto T1249;
+  goto T1224;
+T1249:
+ V648 = (long) V648 + 1;
+  goto T1240;
+T1243:
+  V643 = (object) & Cnil_body;
+T1224:
+  _y = V643;
+  number_plus (_x, _y);
+}
index f97c23db93bbecb9abaafa823d89b8d135a6f674..9d2fe2657912572d1925d1c8ec0b977f17f4c6ea 100644 (file)
@@ -189,8 +189,14 @@ tree_if_conversion (struct loop *loop, bool for_vectorizer)
       if (single_succ_p (bb))
        {
          basic_block bb_n = single_succ (bb);
-         if (cond != NULL_TREE)
-           add_to_predicate_list (bb_n, cond);
+
+         /* Successor bb inherits predicate of its predecessor. If there
+            is no predicate in predecessor bb, then consider successor bb
+            as always executed.  */
+         if (cond == NULL_TREE)
+           cond = boolean_true_node;
+
+         add_to_predicate_list (bb_n, cond);
        }
     }
 
@@ -724,6 +730,8 @@ find_phi_replacement_condition (struct loop *loop,
 
   /* Select condition that is not TRUTH_NOT_EXPR.  */
   tmp_cond = (first_edge->src)->aux;
+  gcc_assert (tmp_cond);
+
   if (TREE_CODE (tmp_cond) == TRUTH_NOT_EXPR)
     {
       edge tmp_edge;