Regression for gcc.dg/Wstrict-overflow-11.c between 124216:124219
Richard Guenther
rguenther@suse.de
Fri Apr 27 18:55:00 GMT 2007
On Fri, 27 Apr 2007, Richard Guenther wrote:
> On 4/27/07, Hans-Peter Nilsson <hans-peter.nilsson@axis.com> wrote:
> > Something in your
> > + PR tree-optimization/30965
> > + PR tree-optimization/30978
> >
> > fix caused a regression for gcc.dg/Wstrict-overflow-11.c (for
> > cris-elf, but that shouldn't matter):
>
> Well, loop header copying introduces a comparison that is always true:
>
> <bb 2>:
> D.1630_13 = i_4(D) + 4;
> if (i_4(D) <= D.1630_13)
> goto <bb 3> (<L0>);
> else
> goto <bb 4> (<L2>);
>
> and before this patch we were not able to fold this. Now we do and
> get this warning.
>
> Which makes me think again that all "compiler generated" code should
> have TREE_NO_WARNING set. Or, Ian, any idea on how to fix _this_
> warning but not warnings from forwprop in general?
So the following fixes it. I'll give it the testing later.
Richard.
2007-04-27 Richard Guenther <rguenther@suse.de>
* tree-ssa-forwprop.c (forward_propagate_into_cond): Keep track
if we simplified anything.
(tree_ssa_forward_propagate_single_use_vars): Defer overflow
warnings until we did a simplification and the stmt was not
marked as TREE_NO_WARNING.
Index: tree-ssa-forwprop.c
===================================================================
*** tree-ssa-forwprop.c (revision 124226)
--- tree-ssa-forwprop.c (working copy)
*************** combine_cond_expr_cond (enum tree_code c
*** 372,380 ****
/* Propagate from the ssa name definition statements of COND_EXPR
in statement STMT into the conditional if that simplifies it. */
! static void
forward_propagate_into_cond (tree cond_expr, tree stmt)
{
do {
tree tmp = NULL_TREE;
tree cond = COND_EXPR_COND (cond_expr);
--- 372,382 ----
/* Propagate from the ssa name definition statements of COND_EXPR
in statement STMT into the conditional if that simplifies it. */
! static bool
forward_propagate_into_cond (tree cond_expr, tree stmt)
{
+ bool did_something = false;
+
do {
tree tmp = NULL_TREE;
tree cond = COND_EXPR_COND (cond_expr);
*************** forward_propagate_into_cond (tree cond_e
*** 407,413 ****
def_stmt = get_prop_source_stmt (name, false, &single_use_p);
if (def_stmt == NULL_TREE
|| !can_propagate_from (def_stmt))
! return;
rhs = GIMPLE_STMT_OPERAND (def_stmt, 1);
tmp = combine_cond_expr_cond (TREE_CODE (cond), boolean_type_node,
--- 409,415 ----
def_stmt = get_prop_source_stmt (name, false, &single_use_p);
if (def_stmt == NULL_TREE
|| !can_propagate_from (def_stmt))
! return did_something;
rhs = GIMPLE_STMT_OPERAND (def_stmt, 1);
tmp = combine_cond_expr_cond (TREE_CODE (cond), boolean_type_node,
*************** forward_propagate_into_cond (tree cond_e
*** 422,428 ****
def_stmt = get_prop_source_stmt (name, true, NULL);
if (def_stmt == NULL_TREE
|| !can_propagate_from (def_stmt))
! return;
rhs = GIMPLE_STMT_OPERAND (def_stmt, 1);
tmp = combine_cond_expr_cond (NE_EXPR, boolean_type_node, rhs,
--- 424,430 ----
def_stmt = get_prop_source_stmt (name, true, NULL);
if (def_stmt == NULL_TREE
|| !can_propagate_from (def_stmt))
! return did_something;
rhs = GIMPLE_STMT_OPERAND (def_stmt, 1);
tmp = combine_cond_expr_cond (NE_EXPR, boolean_type_node, rhs,
*************** forward_propagate_into_cond (tree cond_e
*** 447,458 ****
--- 449,464 ----
/* Remove defining statements. */
remove_prop_source_from_use (name, NULL);
+ did_something = true;
+
/* Continue combining. */
continue;
}
break;
} while (1);
+
+ return did_something;
}
/* We've just substituted an ADDR_EXPR into stmt. Update all the
*************** tree_ssa_forward_propagate_single_use_va
*** 986,992 ****
}
else if (TREE_CODE (rhs) == COND_EXPR)
{
! forward_propagate_into_cond (rhs, stmt);
bsi_next (&bsi);
}
else if (COMPARISON_CLASS_P (rhs))
--- 992,1002 ----
}
else if (TREE_CODE (rhs) == COND_EXPR)
{
! bool did_something;
! fold_defer_overflow_warnings ();
! did_something = forward_propagate_into_cond (rhs, stmt);
! fold_undefer_overflow_warnings (!TREE_NO_WARNING (rhs)
! && did_something, stmt, WARN_STRICT_OVERFLOW_CONDITIONAL);
bsi_next (&bsi);
}
else if (COMPARISON_CLASS_P (rhs))
*************** tree_ssa_forward_propagate_single_use_va
*** 1010,1016 ****
}
else if (TREE_CODE (stmt) == COND_EXPR)
{
! forward_propagate_into_cond (stmt, stmt);
bsi_next (&bsi);
}
else
--- 1020,1031 ----
}
else if (TREE_CODE (stmt) == COND_EXPR)
{
! bool did_something;
! fold_defer_overflow_warnings ();
! did_something = forward_propagate_into_cond (stmt, stmt);
! fold_undefer_overflow_warnings (!TREE_NO_WARNING (stmt)
! && did_something, stmt,
! WARN_STRICT_OVERFLOW_CONDITIONAL);
bsi_next (&bsi);
}
else
More information about the Gcc-patches
mailing list