diff options
author | Kazu Hirata <kazu@cs.umass.edu> | 2005-03-07 03:23:13 +0000 |
---|---|---|
committer | Kazu Hirata <kazu@gcc.gnu.org> | 2005-03-07 03:23:13 +0000 |
commit | 1eaea40908e7e9f4f2b6bb97bcf82a2e35fd6453 (patch) | |
tree | a7eb69b36d0f65d07b93e36e1a32cbb6743f4e92 /gcc | |
parent | 209eaaffeb2d308fc1e2553d95dd34d691f44537 (diff) | |
download | gcc-1eaea40908e7e9f4f2b6bb97bcf82a2e35fd6453.zip gcc-1eaea40908e7e9f4f2b6bb97bcf82a2e35fd6453.tar.gz gcc-1eaea40908e7e9f4f2b6bb97bcf82a2e35fd6453.tar.bz2 |
fold-const.c (fold_binary): Unroll the very first "for" loop.
* fold-const.c (fold_binary): Unroll the very first "for"
loop.
From-SVN: r96003
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 3 | ||||
-rw-r--r-- | gcc/fold-const.c | 58 |
2 files changed, 44 insertions, 17 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 6c46d58..451b7a2 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -2,6 +2,9 @@ * fold-const.c (fold_binary): Remove handling of RANGE_EXPR. + * fold-const.c (fold_binary): Unroll the very first "for" + loop. + 2005-03-06 David Edelsohn <edelsohn@gnu.org> * config/rs6000/predicates.md (branch_comparison_operator): Remove diff --git a/gcc/fold-const.c b/gcc/fold-const.c index b5f919e..e9fd552 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -7038,21 +7038,17 @@ fold_binary (tree expr) /* WINS will be nonzero when the switch is done if all operands are constant. */ int wins = 1; - int i; gcc_assert (IS_EXPR_CODE_CLASS (kind) && TREE_CODE_LENGTH (code) == 2); - op0 = TREE_OPERAND (t, 0); - op1 = TREE_OPERAND (t, 1); - for (i = 0; i < 2; i++) + arg0 = op0 = TREE_OPERAND (t, 0); + arg1 = op1 = TREE_OPERAND (t, 1); + + if (arg0) { - tree op = TREE_OPERAND (t, i); tree subop; - if (op == 0) - continue; /* Valid for CALL_EXPR, at least. */ - /* Strip any conversions that don't change the mode. This is safe for every expression, except for a comparison expression because its signedness is derived from its operands. So, in @@ -7065,14 +7061,14 @@ fold_binary (tree expr) cases, the appropriate type conversions should be put back in the tree that will get out of the constant folder. */ if (kind == tcc_comparison) - STRIP_SIGN_NOPS (op); + STRIP_SIGN_NOPS (arg0); else - STRIP_NOPS (op); + STRIP_NOPS (arg0); - if (TREE_CODE (op) == COMPLEX_CST) - subop = TREE_REALPART (op); + if (TREE_CODE (arg0) == COMPLEX_CST) + subop = TREE_REALPART (arg0); else - subop = op; + subop = arg0; if (TREE_CODE (subop) != INTEGER_CST && TREE_CODE (subop) != REAL_CST) @@ -7080,11 +7076,39 @@ fold_binary (tree expr) static var addresses are constant but we can't do arithmetic on them. */ wins = 0; + } + + if (arg1) + { + tree subop; + + /* Strip any conversions that don't change the mode. This is + safe for every expression, except for a comparison expression + because its signedness is derived from its operands. So, in + the latter case, only strip conversions that don't change the + signedness. - if (i == 0) - arg0 = op; - else if (i == 1) - arg1 = op; + Note that this is done as an internal manipulation within the + constant folder, in order to find the simplest representation + of the arguments so that their form can be studied. In any + cases, the appropriate type conversions should be put back in + the tree that will get out of the constant folder. */ + if (kind == tcc_comparison) + STRIP_SIGN_NOPS (arg1); + else + STRIP_NOPS (arg1); + + if (TREE_CODE (arg1) == COMPLEX_CST) + subop = TREE_REALPART (arg1); + else + subop = arg1; + + if (TREE_CODE (subop) != INTEGER_CST + && TREE_CODE (subop) != REAL_CST) + /* Note that TREE_CONSTANT isn't enough: + static var addresses are constant but we can't + do arithmetic on them. */ + wins = 0; } /* If this is a commutative operation, and ARG0 is a constant, move it |