diff options
author | James A. Morrison <phython@gcc.gnu.org> | 2005-07-20 03:30:58 +0000 |
---|---|---|
committer | James A. Morrison <phython@gcc.gnu.org> | 2005-07-20 03:30:58 +0000 |
commit | 1ade5842af034a0f4e9d606b17ee3ea64375d78a (patch) | |
tree | 1deede4acfc6d0df887b5c1c33abf9c83e1ea611 /gcc/fold-const.c | |
parent | 4038c495fc9685efdb400b36848627daab979e78 (diff) | |
download | gcc-1ade5842af034a0f4e9d606b17ee3ea64375d78a.zip gcc-1ade5842af034a0f4e9d606b17ee3ea64375d78a.tar.gz gcc-1ade5842af034a0f4e9d606b17ee3ea64375d78a.tar.bz2 |
fold-const.c (tree_expr_nonnegative_p): Only return true for ABS_EXPR when flag_wrapv is false because of INT_MIN.
2005-07-19 James A. Morrison <phython@gcc.gnu.org>
* fold-const.c (tree_expr_nonnegative_p): Only return true for
ABS_EXPR when flag_wrapv is false because of INT_MIN.
(tree_expr_nonzero_p): Always call tree_expr_nonzero_p on the argument
of an ABS_EXPR.
(fold_unary): Always fold ABS_EXPR<ABS_EXPR<x>> into
ABS_EXPR<x>.
From-SVN: r102184
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r-- | gcc/fold-const.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 273a912..e9d88d1 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -6827,7 +6827,8 @@ fold_unary (enum tree_code code, tree type, tree op0) TREE_TYPE (targ0), targ0)); } - else if (tree_expr_nonnegative_p (arg0)) + /* ABS_EXPR<ABS_EXPR<x>> = ABS_EXPR<x> even if flag_wrapv is on. */ + else if (tree_expr_nonnegative_p (arg0) || TREE_CODE (arg0) == ABS_EXPR) return arg0; /* Strip sign ops from argument. */ @@ -10527,7 +10528,11 @@ tree_expr_nonnegative_p (tree t) switch (TREE_CODE (t)) { case ABS_EXPR: - return 1; + /* We can't return 1 if flag_wrapv is set because + ABS_EXPR<INT_MIN> = INT_MIN. */ + if (!flag_wrapv) + return 1; + break; case INTEGER_CST: return tree_int_cst_sgn (t) >= 0; @@ -10804,8 +10809,7 @@ tree_expr_nonzero_p (tree t) switch (TREE_CODE (t)) { case ABS_EXPR: - if (!TYPE_UNSIGNED (type) && !flag_wrapv) - return tree_expr_nonzero_p (TREE_OPERAND (t, 0)); + return tree_expr_nonzero_p (TREE_OPERAND (t, 0)); case INTEGER_CST: /* We used to test for !integer_zerop here. This does not work correctly |