From f2532264859701aa0768c8b00e61456ac9ab22a3 Mon Sep 17 00:00:00 2001 From: sayle Date: Wed, 8 Nov 2006 17:39:35 +0000 Subject: [PATCH] * 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) : Use set_rhs to modify the condition after calling fold_binary. * fold-const.c (fold_inf_compare): Remove in_gimple_form check. (fold_binary) : Likewise. * builtins.c (fold_builtin_isascii): Likewise. (fold_builtin_isdigit): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@118593 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 11 +++++++ gcc/builtins.c | 17 +++-------- gcc/fold-const.c | 8 +----- gcc/tree-ssa-ccp.c | 13 +++++---- gcc/tree-ssa-propagate.c | 74 +++++++++++++++++++++++++++++++++++++++--------- 5 files changed, 85 insertions(+), 38 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c110758499c..4fa736f8a35 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,14 @@ +2006-11-08 Roger Sayle + + * 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) : Use set_rhs to modify + the condition after calling fold_binary. + * fold-const.c (fold_inf_compare): Remove in_gimple_form check. + (fold_binary) : Likewise. + * builtins.c (fold_builtin_isascii): Likewise. + (fold_builtin_isdigit): Likewise. + 2006-11-08 Carlos O'Donell * configure.ac: Do not set PREFIX_INCLUDE_DIR if $prefix is NONE. diff --git a/gcc/builtins.c b/gcc/builtins.c index 64bb52b28bb..17355f723fa 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -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)); } } diff --git a/gcc/fold-const.c b/gcc/fold-const.c index d70e5b02605..c74ffa37bde 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -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. */ diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c index 3be926d9cce..0ecd221b30d 100644 --- a/gcc/tree-ssa-ccp.c +++ b/gcc/tree-ssa-ccp.c @@ -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; diff --git a/gcc/tree-ssa-propagate.c b/gcc/tree-ssa-propagate.c index f9ece62a9a8..e367559f0cf 100644 --- a/gcc/tree-ssa-propagate.c +++ b/gcc/tree-ssa-propagate.c @@ -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) -- 2.11.4.GIT