diff options
| author | phython <phython@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-02-14 02:27:18 +0000 |
|---|---|---|
| committer | phython <phython@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-02-14 02:27:18 +0000 |
| commit | b3e5216b04faa3147644b55dfc9268d801dc9906 (patch) | |
| tree | 45f0166013ff03258ca55d7560c8f120cfc3e373 | |
| parent | d83805c312fd0d5a27827c2c7312a7957853f9f1 (diff) | |
| download | ppe42-gcc-b3e5216b04faa3147644b55dfc9268d801dc9906.tar.gz ppe42-gcc-b3e5216b04faa3147644b55dfc9268d801dc9906.zip | |
2005-02-13 James A. Morrison <phython@gcc.gnu.org>
PR tree-optimization/19944
* fold-const.c (fold): Re-add ABS_EXPR folding.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@95002 138bc75d-0d04-0410-961f-82ee72b054a4
| -rw-r--r-- | gcc/ChangeLog | 5 | ||||
| -rw-r--r-- | gcc/fold-const.c | 20 |
2 files changed, 25 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 697588ca1e0..11dbcf766e7 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2005-02-13 James A. Morrison <phython@gcc.gnu.org> + + PR tree-optimization/19944 + * fold-const.c (fold): Re-add ABS_EXPR folding. + 2005-02-13 David Edelsohn <edelsohn@gnu.org> PR target/19019 diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 5d6e5c50854..ae4b7e5396d 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -8973,6 +8973,26 @@ fold (tree expr) build2 (LE_EXPR, type, TREE_OPERAND (arg0, 0), arg1))); + /* Convert ABS_EXPR<x> >= 0 to true. */ + else if (code == GE_EXPR + && tree_expr_nonnegative_p (arg0) + && (integer_zerop (arg1) + || (! HONOR_NANS (TYPE_MODE (TREE_TYPE (arg0))) + && real_zerop (arg1)))) + return omit_one_operand (type, integer_one_node, arg0); + + /* Convert ABS_EXPR<x> < 0 to false. */ + else if (code == LT_EXPR + && tree_expr_nonnegative_p (arg0) + && (integer_zerop (arg1) || real_zerop (arg1))) + return omit_one_operand (type, integer_zero_node, arg0); + + /* Convert ABS_EXPR<x> == 0 or ABS_EXPR<x> != 0 to x == 0 or x != 0. */ + else if ((code == EQ_EXPR || code == NE_EXPR) + && TREE_CODE (arg0) == ABS_EXPR + && (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 |

