From e650cbda8f5c83228925a222d2690c606755df29 Mon Sep 17 00:00:00 2001 From: Richard Kenner Date: Wed, 17 Aug 1994 18:03:37 -0400 Subject: [PATCH] (fold_rtx): When folding tablejump, allow LABEL_REF to be in arg0; also allow other arg to be MINUS, not just be equivalent to it. From-SVN: r7939 --- gcc/cse.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/gcc/cse.c b/gcc/cse.c index b929fb5c58f..4902b897976 100644 --- a/gcc/cse.c +++ b/gcc/cse.c @@ -5369,20 +5369,43 @@ fold_rtx (x, insn) ADDR_DIFF_VEC table. */ if (const_arg1 && GET_CODE (const_arg1) == LABEL_REF) { - rtx y = lookup_as_function (folded_arg0, MINUS); + rtx y + = GET_CODE (folded_arg0) == MINUS ? folded_arg0 + : lookup_as_function (folded_arg0, MINUS); if (y != 0 && GET_CODE (XEXP (y, 1)) == LABEL_REF && XEXP (XEXP (y, 1), 0) == XEXP (const_arg1, 0)) return XEXP (y, 0); /* Now try for a CONST of a MINUS like the above. */ - if ((y = lookup_as_function (folded_arg0, CONST)) != 0 + if ((y = (GET_CODE (folded_arg0) == CONST ? folded_arg0 + : lookup_as_function (folded_arg0, CONST))) != 0 && GET_CODE (XEXP (y, 0)) == MINUS && GET_CODE (XEXP (XEXP (y, 0), 1)) == LABEL_REF && XEXP (XEXP (XEXP (y, 0),1), 0) == XEXP (const_arg1, 0)) return XEXP (XEXP (y, 0), 0); } + /* Likewise if the operands are in the other order. */ + if (const_arg0 && GET_CODE (const_arg0) == LABEL_REF) + { + rtx y + = GET_CODE (folded_arg1) == MINUS ? folded_arg1 + : lookup_as_function (folded_arg1, MINUS); + + if (y != 0 && GET_CODE (XEXP (y, 1)) == LABEL_REF + && XEXP (XEXP (y, 1), 0) == XEXP (const_arg0, 0)) + return XEXP (y, 0); + + /* Now try for a CONST of a MINUS like the above. */ + if ((y = (GET_CODE (folded_arg1) == CONST ? folded_arg1 + : lookup_as_function (folded_arg1, CONST))) != 0 + && GET_CODE (XEXP (y, 0)) == MINUS + && GET_CODE (XEXP (XEXP (y, 0), 1)) == LABEL_REF + && XEXP (XEXP (XEXP (y, 0),1), 0) == XEXP (const_arg0, 0)) + return XEXP (XEXP (y, 0), 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