This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/47271] [4.6 Regression] if-conversion removes a test (if), the function generates invalid outputs
- From: "spop at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 24 Jan 2011 18:56:14 +0000
- Subject: [Bug tree-optimization/47271] [4.6 Regression] if-conversion removes a test (if), the function generates invalid outputs
- Auto-submitted: auto-generated
- References: <bug-47271-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47271
--- Comment #10 from Sebastian Pop <spop at gcc dot gnu.org> 2011-01-24 18:55:48 UTC ---
The BB of the phi node to be rewritten should post-dominate the BBs in which
the arguments of the phi node are defined. The following gcc_assert will ICE
when the translation done in predicate_scalar_phi is unsafe:
diff --git a/gcc/tree-if-conv.c b/gcc/tree-if-conv.c
index cc7ad8a..9a3e2b5 100644
--- a/gcc/tree-if-conv.c
+++ b/gcc/tree-if-conv.c
@@ -992,6 +992,7 @@ if_convertible_loop_p_1 (struct loop *loop,
return false;
calculate_dominance_info (CDI_DOMINATORS);
+ calculate_dominance_info (CDI_POST_DOMINATORS);
/* Allow statements that can be handled during if-conversion. */
ifc_bbs = get_loop_body_in_if_conv_order (loop);
@@ -1244,6 +1245,15 @@ predicate_scalar_phi (gimple phi, tree cond,
arg_1 = gimple_phi_arg_def (phi, 1);
}
+ gcc_assert ((TREE_CODE (arg_0) != SSA_NAME
+ || dominated_by_p (CDI_POST_DOMINATORS,
+ gimple_bb (SSA_NAME_DEF_STMT (arg_0)),
+ bb))
+ && (TREE_CODE (arg_1) != SSA_NAME
+ || dominated_by_p (CDI_POST_DOMINATORS,
+ gimple_bb (SSA_NAME_DEF_STMT (arg_1)),
+ bb)));
+
/* Build new RHS using selected condition and arguments. */
rhs = build3 (COND_EXPR, TREE_TYPE (res),
unshare_expr (cond), arg_0, arg_1);