From a2cd028f5fd512c04e4fdce69d4398d13b51cfb9 Mon Sep 17 00:00:00 2001 From: Janis Johnson Date: Wed, 6 Feb 2002 22:13:01 +0000 Subject: [PATCH] loop.c (remove_constant_addition): Avoid clobbering a shared CONST expression. * loop.c (remove_constant_addition): Avoid clobbering a shared CONST expression. Co-Authored-By: Jan Hubicka From-SVN: r49556 --- gcc/ChangeLog | 6 ++++++ gcc/loop.c | 13 ++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) 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);