summaryrefslogtreecommitdiff
path: root/gcc/fold-const.c
diff options
context:
space:
mode:
authorphython <phython@138bc75d-0d04-0410-961f-82ee72b054a4>2005-07-20 03:30:58 +0000
committerphython <phython@138bc75d-0d04-0410-961f-82ee72b054a4>2005-07-20 03:30:58 +0000
commit8040d1c5b709efbb7114f788e44b4099cb9a8190 (patch)
tree1deede4acfc6d0df887b5c1c33abf9c83e1ea611 /gcc/fold-const.c
parentc75b4594282e6b33803b8332acba704d057f8d97 (diff)
downloadgcc-8040d1c5b709efbb7114f788e44b4099cb9a8190.tar.gz
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>. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@102184 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r--gcc/fold-const.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 273a912d4e4..e9d88d1e6c3 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