tree-ssa-propagate.c (set_rhs): Restructure validity tests as a test for inclusion rather than as a test for...

* tree-ssa-propagate.c (set_rhs): Restructure validity tests as a
	test for inclusion rather than as a test for exclusion.
	* tree-ssa-ccp.c (fold_stmt_r) <COND_EXPR>: Use set_rhs to modify
	the condition after calling fold_binary.
	* fold-const.c (fold_inf_compare): Remove in_gimple_form check.
	(fold_binary) <LT_EXPR, GT_EXPR, LE_EXPR, GE_EXPR>: Likewise.
	* builtins.c (fold_builtin_isascii): Likewise.
	(fold_builtin_isdigit): Likewise.

From-SVN: r118593
This commit is contained in:
Roger Sayle 2006-11-08 17:39:35 +00:00 committed by Roger Sayle
parent c794c06fef
commit 5cdc4a2674
5 changed files with 85 additions and 38 deletions

View File

@ -1,3 +1,14 @@
2006-11-08 Roger Sayle <roger@eyesopen.com>
* tree-ssa-propagate.c (set_rhs): Restructure validity tests as a
test for inclusion rather than as a test for exclusion.
* tree-ssa-ccp.c (fold_stmt_r) <COND_EXPR>: Use set_rhs to modify
the condition after calling fold_binary.
* fold-const.c (fold_inf_compare): Remove in_gimple_form check.
(fold_binary) <LT_EXPR, GT_EXPR, LE_EXPR, GE_EXPR>: Likewise.
* builtins.c (fold_builtin_isascii): Likewise.
(fold_builtin_isdigit): Likewise.
2006-11-08 Carlos O'Donell <carlos@codesourcery.com>
* configure.ac: Do not set PREFIX_INCLUDE_DIR if $prefix is NONE.

View File

@ -8758,13 +8758,8 @@ fold_builtin_isascii (tree arglist)
arg = build2 (BIT_AND_EXPR, integer_type_node, arg,
build_int_cst (NULL_TREE,
~ (unsigned HOST_WIDE_INT) 0x7f));
arg = fold_build2 (EQ_EXPR, integer_type_node,
arg, integer_zero_node);
if (in_gimple_form && !TREE_CONSTANT (arg))
return NULL_TREE;
else
return arg;
return fold_build2 (EQ_EXPR, integer_type_node,
arg, integer_zero_node);
}
}
@ -8807,12 +8802,8 @@ fold_builtin_isdigit (tree arglist)
arg = fold_convert (unsigned_type_node, TREE_VALUE (arglist));
arg = build2 (MINUS_EXPR, unsigned_type_node, arg,
build_int_cst (unsigned_type_node, target_digit0));
arg = fold_build2 (LE_EXPR, integer_type_node, arg,
build_int_cst (unsigned_type_node, 9));
if (in_gimple_form && !TREE_CONSTANT (arg))
return NULL_TREE;
else
return arg;
return fold_build2 (LE_EXPR, integer_type_node, arg,
build_int_cst (unsigned_type_node, 9));
}
}

View File

@ -6059,11 +6059,6 @@ fold_inf_compare (enum tree_code code, tree type, tree arg0, tree arg1)
return fold_build2 (neg ? GE_EXPR : LE_EXPR, type,
arg0, build_real (TREE_TYPE (arg0), max));
/* The transformation below creates non-gimple code and thus is
not appropriate if we are in gimple form. */
if (in_gimple_form)
return NULL_TREE;
temp = fold_build2 (neg ? LT_EXPR : GT_EXPR, type,
arg0, build_real (TREE_TYPE (arg0), max));
return fold_build1 (TRUTH_NOT_EXPR, type, temp);
@ -11043,8 +11038,7 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1)
break;
}
else if (!in_gimple_form
&& TREE_INT_CST_HIGH (arg1) == signed_max_hi
else if (TREE_INT_CST_HIGH (arg1) == signed_max_hi
&& TREE_INT_CST_LOW (arg1) == signed_max_lo
&& TYPE_UNSIGNED (TREE_TYPE (arg1))
/* signed_type does not work on pointer types. */

View File

@ -2048,12 +2048,15 @@ fold_stmt_r (tree *expr_p, int *walk_subtrees, void *data)
{
tree op0 = TREE_OPERAND (expr, 0);
tree tem = fold_binary (TREE_CODE (op0), TREE_TYPE (op0),
TREE_OPERAND (op0, 0), TREE_OPERAND (op0, 1));
if (tem && is_gimple_condexpr (tem))
TREE_OPERAND (expr, 0) = tem;
t = expr;
break;
TREE_OPERAND (op0, 0),
TREE_OPERAND (op0, 1));
if (tem && set_rhs (expr_p, tem))
{
t = *expr_p;
break;
}
}
return NULL_TREE;
default:
return NULL_TREE;

View File

@ -571,26 +571,74 @@ set_rhs (tree *stmt_p, tree expr)
ssa_op_iter iter;
/* Verify the constant folded result is valid gimple. */
if (TREE_CODE_CLASS (code) == tcc_binary)
switch (TREE_CODE_CLASS (code))
{
case tcc_declaration:
if (!is_gimple_variable(expr))
return false;
break;
case tcc_constant:
break;
case tcc_binary:
case tcc_comparison:
if (!is_gimple_val (TREE_OPERAND (expr, 0))
|| !is_gimple_val (TREE_OPERAND (expr, 1)))
return false;
}
else if (TREE_CODE_CLASS (code) == tcc_unary)
{
break;
case tcc_unary:
if (!is_gimple_val (TREE_OPERAND (expr, 0)))
return false;
break;
case tcc_expression:
switch (code)
{
case ADDR_EXPR:
if (TREE_CODE (TREE_OPERAND (expr, 0)) == ARRAY_REF
&& !is_gimple_val (TREE_OPERAND (TREE_OPERAND (expr, 0), 1)))
return false;
break;
case TRUTH_NOT_EXPR:
if (!is_gimple_val (TREE_OPERAND (expr, 0)))
return false;
break;
case TRUTH_AND_EXPR:
case TRUTH_XOR_EXPR:
case TRUTH_OR_EXPR:
if (!is_gimple_val (TREE_OPERAND (expr, 0))
|| !is_gimple_val (TREE_OPERAND (expr, 1)))
return false;
break;
case CALL_EXPR:
case EXC_PTR_EXPR:
case FILTER_EXPR:
break;
default:
return false;
}
break;
case tcc_exceptional:
switch (code)
{
case SSA_NAME:
break;
default:
return false;
}
break;
default:
return false;
}
else if (code == ADDR_EXPR)
{
if (TREE_CODE (TREE_OPERAND (expr, 0)) == ARRAY_REF
&& !is_gimple_val (TREE_OPERAND (TREE_OPERAND (expr, 0), 1)))
return false;
}
else if (code == COMPOUND_EXPR
|| code == MODIFY_EXPR)
return false;
if (EXPR_HAS_LOCATION (stmt)
&& EXPR_P (expr)