aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Kenner <kenner@gcc.gnu.org>1997-04-21 16:30:16 -0400
committerRichard Kenner <kenner@gcc.gnu.org>1997-04-21 16:30:16 -0400
commit5d595063ff7a2203d967ac9d10517f8e88bd13a7 (patch)
treedeb5b044b7ebfc328a26581631c3e0f1e5c47db2 /gcc
parent9ee3c6873784cc2f98e2fbdc55293dd76423aefa (diff)
downloadgcc-5d595063ff7a2203d967ac9d10517f8e88bd13a7.zip
gcc-5d595063ff7a2203d967ac9d10517f8e88bd13a7.tar.gz
gcc-5d595063ff7a2203d967ac9d10517f8e88bd13a7.tar.bz2
(fold_rtx, case PLUS): When seeing if negative of constant is around,
make sure not dealing with largest negative. From-SVN: r13953
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cse.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/gcc/cse.c b/gcc/cse.c
index f180075..260da29 100644
--- a/gcc/cse.c
+++ b/gcc/cse.c
@@ -5581,11 +5581,17 @@ fold_rtx (x, insn)
/* 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
+ a non-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)
+ constant previously-used is the more common case. Be sure
+ the resulting constant is non-negative; if const_arg1 were
+ the smallest negative number this would overflow: depending
+ on the mode, this would either just be the same value (and
+ hence not save anything) or be incorrect. */
+ if (const_arg1 != 0 && GET_CODE (const_arg1) == CONST_INT
+ && INTVAL (const_arg1) < 0
+ && - INTVAL (const_arg1) >= 0
+ && GET_CODE (folded_arg1) == REG)
{
rtx new_const = GEN_INT (- INTVAL (const_arg1));
struct table_elt *p