tree.h (tree_expr_nonzero_p): Export.
2005-07-20 James A. Morrison <phython@gcc.gnu.org> * tree.h (tree_expr_nonzero_p): Export. * fold-const.c (tree_expr_nonzero_p): Likewise. Return true for CALL_EXPRs that are alloca calls. (fold_binary): Use omit_one_operand when checking EQ_EXPRs or NE_EXPRs against zero. * tree-flow.h (expr_computes_nonzero): Remove. * tree-vrp.c (expr_computes_nonzero): Remove. (vrp_expr_computes_nonzero): Use tree_expr_nonzero_p. (extract_range_from_unary_expr): Likewise. * tree-ssa-dom.c (record_equivalences_from_stmt): Use tree_expr_nonzero_p. From-SVN: r102201
This commit is contained in:
parent
09350e36ee
commit
4db8040cd4
8 changed files with 46 additions and 39 deletions
|
@ -1,3 +1,17 @@
|
|||
2005-07-20 James A. Morrison <phython@gcc.gnu.org>
|
||||
|
||||
* tree.h (tree_expr_nonzero_p): Export.
|
||||
* fold-const.c (tree_expr_nonzero_p): Likewise.
|
||||
Return true for CALL_EXPRs that are alloca calls.
|
||||
(fold_binary): Use omit_one_operand when checking EQ_EXPRs or NE_EXPRs
|
||||
against zero.
|
||||
* tree-flow.h (expr_computes_nonzero): Remove.
|
||||
* tree-vrp.c (expr_computes_nonzero): Remove.
|
||||
(vrp_expr_computes_nonzero): Use tree_expr_nonzero_p.
|
||||
(extract_range_from_unary_expr): Likewise.
|
||||
* tree-ssa-dom.c (record_equivalences_from_stmt): Use
|
||||
tree_expr_nonzero_p.
|
||||
|
||||
2005-07-20 Bernd Schmidt <bernd.schmidt@analog.com>
|
||||
|
||||
* config/bfin/bfin-protos.h (legitimize_pic_address): Don't declare.
|
||||
|
|
|
@ -132,7 +132,6 @@ static bool reorder_operands_p (tree, tree);
|
|||
static tree fold_negate_const (tree, tree);
|
||||
static tree fold_not_const (tree, tree);
|
||||
static tree fold_relational_const (enum tree_code, tree, tree, tree);
|
||||
static bool tree_expr_nonzero_p (tree);
|
||||
|
||||
/* We know that A1 + B1 = SUM1, using 2's complement arithmetic and ignoring
|
||||
overflow. Suppose A, B and SUM have the same respective signs as A1, B1,
|
||||
|
@ -9694,10 +9693,12 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1)
|
|||
}
|
||||
|
||||
if ((code == EQ_EXPR || code == NE_EXPR)
|
||||
&& !TREE_SIDE_EFFECTS (arg0)
|
||||
&& integer_zerop (arg1)
|
||||
&& tree_expr_nonzero_p (arg0))
|
||||
return constant_boolean_node (code==NE_EXPR, type);
|
||||
{
|
||||
tree res = constant_boolean_node (code==NE_EXPR, type);
|
||||
return omit_one_operand (type, res, arg0);
|
||||
}
|
||||
|
||||
t1 = fold_relational_const (code, type, arg0, arg1);
|
||||
return t1 == NULL_TREE ? NULL_TREE : t1;
|
||||
|
@ -10797,7 +10798,7 @@ tree_expr_nonnegative_p (tree t)
|
|||
For floating point we further ensure that T is not denormal.
|
||||
Similar logic is present in nonzero_address in rtlanal.h. */
|
||||
|
||||
static bool
|
||||
bool
|
||||
tree_expr_nonzero_p (tree t)
|
||||
{
|
||||
tree type = TREE_TYPE (t);
|
||||
|
@ -10904,6 +10905,9 @@ tree_expr_nonzero_p (tree t)
|
|||
return tree_expr_nonzero_p (TREE_OPERAND (t, 1))
|
||||
|| tree_expr_nonzero_p (TREE_OPERAND (t, 0));
|
||||
|
||||
case CALL_EXPR:
|
||||
return alloca_call_p (t);
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
2005-07-20 James A. Morrison <phython@gcc.gnu.org>
|
||||
|
||||
* gcc.dg/fold-alloc-1.c: New test.
|
||||
|
||||
2005-07-20 Kazu Hirata <kazu@codesourcery.com>
|
||||
|
||||
* gcc.dg/20020312-2.c, gcc.dg/sibcall-3.c, gcc.dg/sibcall-4.c,
|
||||
|
|
14
gcc/testsuite/gcc.dg/fold-alloca-1.c
Normal file
14
gcc/testsuite/gcc.dg/fold-alloca-1.c
Normal file
|
@ -0,0 +1,14 @@
|
|||
/* { dg-do compile } */
|
||||
/* { dg-options "-fdump-tree-useless" } */
|
||||
|
||||
void *alloca (__SIZE_TYPE__);
|
||||
void link_error ();
|
||||
|
||||
int main (int argc, char *argv[]) {
|
||||
char *foo;
|
||||
if ((foo = alloca(argc)) == 0)
|
||||
link_error ();
|
||||
return 0;
|
||||
}
|
||||
/* { dg-final { scan-tree-dump-times "link_error" 0 "useless" } } */
|
||||
/* { dg-final { cleanup-tree-dump "useless" } } */
|
|
@ -659,7 +659,6 @@ bool fold_stmt_inplace (tree);
|
|||
tree widen_bitfield (tree, tree, tree);
|
||||
|
||||
/* In tree-vrp.c */
|
||||
bool expr_computes_nonzero (tree);
|
||||
tree vrp_evaluate_conditional (tree, bool);
|
||||
void simplify_stmt_using_ranges (tree);
|
||||
|
||||
|
|
|
@ -2633,7 +2633,7 @@ record_equivalences_from_stmt (tree stmt,
|
|||
|| is_gimple_min_invariant (rhs)))
|
||||
SSA_NAME_VALUE (lhs) = rhs;
|
||||
|
||||
if (expr_computes_nonzero (rhs))
|
||||
if (tree_expr_nonzero_p (rhs))
|
||||
record_var_is_nonzero (lhs);
|
||||
}
|
||||
|
||||
|
|
|
@ -95,36 +95,6 @@ static sbitmap blocks_visited;
|
|||
static value_range_t **vr_value;
|
||||
|
||||
|
||||
/* Return true if EXPR computes a non-zero value. */
|
||||
|
||||
bool
|
||||
expr_computes_nonzero (tree expr)
|
||||
{
|
||||
/* Type casts won't change anything, so just strip them. */
|
||||
STRIP_NOPS (expr);
|
||||
|
||||
/* Calling alloca, guarantees that the value is non-NULL. */
|
||||
if (alloca_call_p (expr))
|
||||
return true;
|
||||
|
||||
/* The address of a non-weak symbol is never NULL, unless the user
|
||||
has requested not to remove NULL pointer checks. */
|
||||
if (flag_delete_null_pointer_checks
|
||||
&& TREE_CODE (expr) == ADDR_EXPR
|
||||
&& VAR_OR_FUNCTION_DECL_P (TREE_OPERAND (expr, 0))
|
||||
&& !DECL_WEAK (TREE_OPERAND (expr, 0)))
|
||||
return true;
|
||||
|
||||
/* IOR of any value with a nonzero value will result in a nonzero
|
||||
value. */
|
||||
if (TREE_CODE (expr) == BIT_IOR_EXPR
|
||||
&& integer_nonzerop (TREE_OPERAND (expr, 1)))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/* Return true if ARG is marked with the nonnull attribute in the
|
||||
current function signature. */
|
||||
|
||||
|
@ -393,13 +363,13 @@ symbolic_range_p (value_range_t *vr)
|
|||
}
|
||||
|
||||
|
||||
/* Like expr_computes_nonzero, but this function uses value ranges
|
||||
/* Like tree_expr_nonzero_p, but this function uses value ranges
|
||||
obtained so far. */
|
||||
|
||||
static bool
|
||||
vrp_expr_computes_nonzero (tree expr)
|
||||
{
|
||||
if (expr_computes_nonzero (expr))
|
||||
if (tree_expr_nonzero_p (expr))
|
||||
return true;
|
||||
|
||||
/* If we have an expression of the form &X->a, then the expression
|
||||
|
@ -1319,7 +1289,7 @@ extract_range_from_unary_expr (value_range_t *vr, tree expr)
|
|||
determining if it evaluates to NULL [0, 0] or non-NULL (~[0, 0]). */
|
||||
if (POINTER_TYPE_P (TREE_TYPE (expr)) || POINTER_TYPE_P (TREE_TYPE (op0)))
|
||||
{
|
||||
if (range_is_nonnull (&vr0) || expr_computes_nonzero (expr))
|
||||
if (range_is_nonnull (&vr0) || tree_expr_nonzero_p (expr))
|
||||
set_value_range_to_nonnull (vr, TREE_TYPE (expr));
|
||||
else if (range_is_null (&vr0))
|
||||
set_value_range_to_null (vr, TREE_TYPE (expr));
|
||||
|
|
|
@ -3851,6 +3851,8 @@ extern enum tree_code swap_tree_comparison (enum tree_code);
|
|||
extern bool ptr_difference_const (tree, tree, HOST_WIDE_INT *);
|
||||
extern enum tree_code invert_tree_comparison (enum tree_code, bool);
|
||||
|
||||
extern bool tree_expr_nonzero_p (tree);
|
||||
|
||||
/* In builtins.c */
|
||||
extern tree fold_builtin (tree, tree, bool);
|
||||
extern tree fold_builtin_fputs (tree, bool, bool, tree);
|
||||
|
|
Loading…
Add table
Reference in a new issue