This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PR/18308: ice-on-valid because of non-GIMPLE


This patch is a fix for PR18308, an ice-on-valid that happens
when the vectorizer cannot make use of a COND_EXPR produced
by tree-level if-conversion.  In this case, TER can combine
two COND_EXPRs in a way that is not recognized by do_jump:
fixing this part is easy because COND_EXPRs are recognized
by expand_expr_real_1 which is where do_jump's default label
goes.

Actually, what ifcvt produces is completely non-GIMPLE:

_ifc_.2_15 = (j_6 != 0 || !_ifc_.1_16) && ivtmp.0_4 != 0;

So, this patch also contains an hunk that Devang Patel posted
in the PR's audit trail, which forces operands of its COND_EXPR
to be GIMPLE.

Bootstrapped/regtested i686-pc-linux-gnu, and confirmed that
it produces valid code for the testcase on arm-unknown-elf.
Unlike the one in the audit trail, this test case does not
rely on an uninitialized variable.

Ok for mainline?

Paolo

2004-12-28  Paolo Bonzini  <bonzini@gnu.org>
	    Devang Patel  <dpatel@apple.com>

	PR tree-optimization/18308

	* tree-if-conv.c (add_to_dst_predicate_list): Gimplify
	the operands before creating a new expression.
	* dojump.c (do_jump): Expand COND_EXPRs.

2004-12-28  Paolo Bonzini  <bonzini@gnu.org>

	* gcc.dg/20041228-1.c: New testcase.

--- tree-if-conv.c.save	2004-12-28 19:26:53.000000000 +0100
+++ tree-if-conv.c	2004-12-28 19:11:30.000000000 +0100
@@ -639,7 +639,19 @@
     new_cond = unshare_expr (cond);
   else
     {
-      tree tmp_stmt;
+      tree tmp_stmt = NULL_TREE;
+      tree tmp_stmts1 = NULL_TREE;
+      tree tmp_stmts2 = NULL_TREE;
+      prev_cond = force_gimple_operand (unshare_expr (prev_cond),
+					&tmp_stmts1, true, NULL);
+      if (tmp_stmts1)
+        bsi_insert_before (bsi, tmp_stmts1, BSI_SAME_STMT);
+
+      cond = force_gimple_operand (unshare_expr (cond),
+				   &tmp_stmts2, true, NULL);
+      if (tmp_stmts2)
+        bsi_insert_before (bsi, tmp_stmts2, BSI_SAME_STMT);
+
       /* new_cond == prev_cond AND cond */
       tree tmp = build (TRUTH_AND_EXPR, boolean_type_node,
 			unshare_expr (prev_cond), cond);
--- dojump.c.save	2004-12-28 19:25:30.000000000 +0100
+++ dojump.c	2004-12-28 19:24:25.000000000 +0100
@@ -269,7 +269,6 @@
     case TRUTH_ANDIF_EXPR:
     case TRUTH_ORIF_EXPR:
     case COMPOUND_EXPR:
-    case COND_EXPR:
       /* Lowered by gimplify.c.  */
       gcc_unreachable ();
 


/* { dg-do compile } */
/* { dg-options "-O -ftree-vectorize -funroll-loops" } */
void foo();

void bar(int j)
{
  int i, k=0;
  for (i = 0; i < 2; ++i)
    if (j) k = 2;

  if (k) foo();
}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]