diff options
author | Richard Kenner <kenner@gcc.gnu.org> | 1993-12-26 07:55:11 -0500 |
---|---|---|
committer | Richard Kenner <kenner@gcc.gnu.org> | 1993-12-26 07:55:11 -0500 |
commit | c2cc077888d46ed6c75ad56599af8d78da74b317 (patch) | |
tree | 50547e360c759c9f023e73579b0f2702d78f919a | |
parent | 75600ead0c51e477b2993ff06ec7810636def420 (diff) | |
download | gcc-c2cc077888d46ed6c75ad56599af8d78da74b317.zip gcc-c2cc077888d46ed6c75ad56599af8d78da74b317.tar.gz gcc-c2cc077888d46ed6c75ad56599af8d78da74b317.tar.bz2 |
(fold_rtx...
(fold_rtx, case PLUS): If we have (plus A B), A is equivalent to a
negative constant, and the negated constant is in register, convert to
(minus A C) where C is the register containing the negated constant.
From-SVN: r6326
-rw-r--r-- | gcc/cse.c | 21 |
1 files changed, 21 insertions, 0 deletions
@@ -5350,6 +5350,27 @@ fold_rtx (x, insn) && XEXP (XEXP (y, 1), 0) == XEXP (const_arg1, 0)) return XEXP (y, 0); } + + /* If second operand is a register equivalent to a negative + CONST_INT, see if we can find a register equivalent to the + positive constant. Make a MINUS if so. Don't do this for + a negative constant since we might then alternate between + chosing positive and negative constants. Having the positive + constant previously-used is the more common case. */ + if (const_arg1 && GET_CODE (const_arg1) == CONST_INT + && INTVAL (const_arg1) < 0 && GET_CODE (folded_arg1) == REG) + { + rtx new_const = GEN_INT (- INTVAL (const_arg1)); + struct table_elt *p + = lookup (new_const, safe_hash (new_const, mode) % NBUCKETS, + mode); + + if (p) + for (p = p->first_same_value; p; p = p->next_same_value) + if (GET_CODE (p->exp) == REG) + return cse_gen_binary (MINUS, mode, folded_arg0, + canon_reg (p->exp, NULL_RTX)); + } goto from_plus; case MINUS: |