From 60a8fb5ea9912d3e4efa5cf8393cc23b81034f76 Mon Sep 17 00:00:00 2001 From: "James A. Morrison" Date: Sun, 13 Feb 2005 06:21:35 +0000 Subject: re PR tree-optimization/14303 ([tree-ssa] gcc.c-torture/execute/20020720-1.c is not fully folded) 2005-02-13 James A. Morrison PR tree-optimization/14303 PR tree-optimization/15784 * fold-const.c (fold): Fold ABS_EXPR >= 0 to true, when possible. Fold ABS_EXPR < 0 to false. Fold ABS_EXPR == 0 to x == 0 and ABS_EXPR != 0 to x != 0. From-SVN: r94977 --- gcc/fold-const.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'gcc/fold-const.c') diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 5d6e5c50..601f023 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -8973,6 +8973,29 @@ fold (tree expr) build2 (LE_EXPR, type, TREE_OPERAND (arg0, 0), arg1))); + /* Convert ABS_EXPR >= 0 to true. */ + else if (code == GE_EXPR + && tree_expr_nonnegative_p (arg0) + && ! TREE_SIDE_EFFECTS (arg0) + && (integer_zerop (arg1) + || (! HONOR_NANS (TYPE_MODE (TREE_TYPE (arg0))) + && real_zerop (arg1)))) + return constant_boolean_node (true, type); + + /* Convert ABS_EXPR < 0 to false. */ + else if (code == LT_EXPR + && tree_expr_nonnegative_p (arg0) + && ! TREE_SIDE_EFFECTS (arg0) + && (integer_zerop (arg1) || real_zerop (arg1))) + return constant_boolean_node (false, type); + + /* Convert ABS_EXPR == 0 or ABS_EXPR != 0 to x == 0 or x != 0. */ + else if ((code == EQ_EXPR || code == NE_EXPR) + && TREE_CODE (arg0) == ABS_EXPR + && ! TREE_SIDE_EFFECTS (arg0) + && (integer_zerop (arg1) || real_zerop (arg1))) + return fold (build2 (code, type, TREE_OPERAND (arg0, 0), arg1)); + /* If this is an EQ or NE comparison with zero and ARG0 is (1 << foo) & bar, convert it to (bar >> foo) & 1. Both require two operations, but the latter can be done in one less insn -- cgit v1.1