diff options
| author | hp <hp@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-02-01 21:15:54 +0000 |
|---|---|---|
| committer | hp <hp@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-02-01 21:15:54 +0000 |
| commit | 9d3874a69e9c65c78d5470bc1d75fffd9b33712c (patch) | |
| tree | e70ddc7be04aa34ecfa022123c32a5a39296a2c3 | |
| parent | 17c6c7fc6e739d0ca499dde18b569b6c15b5a49a (diff) | |
| download | ppe42-gcc-9d3874a69e9c65c78d5470bc1d75fffd9b33712c.tar.gz ppe42-gcc-9d3874a69e9c65c78d5470bc1d75fffd9b33712c.zip | |
* cse.c (fold_rtx) <case RTX_COMM_COMPARE, RTX_COMPARE>: When arg1
has a constant equivalent, iterate over equivalents for arg0,
calling simplify_relational_operation and if there's a result
cheaper than X, apply fold_rtx and return the result.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@110481 138bc75d-0d04-0410-961f-82ee72b054a4
| -rw-r--r-- | gcc/ChangeLog | 7 | ||||
| -rw-r--r-- | gcc/cse.c | 51 |
2 files changed, 58 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 1898c2a16c9..fb24b92b16e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2006-02-01 Hans-Peter Nilsson <hp@axis.com> + + * cse.c (fold_rtx) <case RTX_COMM_COMPARE, RTX_COMPARE>: When arg1 + has a constant equivalent, iterate over equivalents for arg0, + calling simplify_relational_operation and if there's a result + cheaper than X, apply fold_rtx and return the result. + 2006-02-01 Jan Hubicka <jh@suse.cz> * opts.c (no_unit_at_a_time_default): New global variable. diff --git a/gcc/cse.c b/gcc/cse.c index 3d2f6b43d5e..8163c6445ac 100644 --- a/gcc/cse.c +++ b/gcc/cse.c @@ -3981,6 +3981,57 @@ fold_rtx (rtx x, rtx insn) comparison. */ if (const_arg0 == 0 || const_arg1 == 0) { + if (const_arg1 != NULL) + { + rtx cheapest_simplification; + int cheapest_cost; + rtx simp_result; + struct table_elt *p; + + /* See if we can find an equivalent of folded_arg0 + that gets us a cheaper expression, possibly a + constant through simplifications. */ + p = lookup (folded_arg0, SAFE_HASH (folded_arg0, mode_arg0), + mode_arg0); + + if (p != NULL) + { + cheapest_simplification = x; + cheapest_cost = COST (x); + + for (p = p->first_same_value; p != NULL; p = p->next_same_value) + { + int cost; + + /* If the entry isn't valid, skip it. */ + if (! exp_equiv_p (p->exp, p->exp, 1, false)) + continue; + + /* Try to simplify using this equivalence. */ + simp_result + = simplify_relational_operation (code, mode, + mode_arg0, + p->exp, + const_arg1); + + if (simp_result == NULL) + continue; + + cost = COST (simp_result); + if (cost < cheapest_cost) + { + cheapest_cost = cost; + cheapest_simplification = simp_result; + } + } + + /* If we have a cheaper expression now, use that + and try folding it further, from the top. */ + if (cheapest_simplification != x) + return fold_rtx (cheapest_simplification, insn); + } + } + /* Some addresses are known to be nonzero. We don't know their sign, but equality comparisons are known. */ if (const_arg1 == const0_rtx |

