diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 778b0d7c621..6b413d62b1c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2002-02-06 Janis Johnson + Jan Hubicka + + * loop.c (remove_constant_addition): Avoid clobbering a shared + CONST expression. + 2002-02-06 Ulrich Weigand * config.gcc (s390x-*-linux*): Add t-linux64 makefile fragment. diff --git a/gcc/loop.c b/gcc/loop.c index 0067e7490fd..e0847a8c32f 100644 --- a/gcc/loop.c +++ b/gcc/loop.c @@ -3683,8 +3683,19 @@ remove_constant_addition (x) HOST_WIDE_INT addval = 0; rtx exp = *x; + /* Avoid clobbering a shared CONST expression. */ if (GET_CODE (exp) == CONST) - exp = XEXP (exp, 0); + { + if (GET_CODE (XEXP (exp, 0)) == PLUS + && GET_CODE (XEXP (XEXP (exp, 0), 0)) == SYMBOL_REF + && GET_CODE (XEXP (XEXP (exp, 0), 1)) == CONST_INT) + { + *x = XEXP (XEXP (exp, 0), 0); + return INTVAL (XEXP (XEXP (exp, 0), 1)); + } + return 0; + } + if (GET_CODE (exp) == CONST_INT) { addval = INTVAL (exp);