summaryrefslogtreecommitdiff
path: root/gcc/cse.c
diff options
context:
space:
mode:
authorRichard Kenner <kenner@gcc.gnu.org>1994-07-30 12:58:42 -0400
committerRichard Kenner <kenner@gcc.gnu.org>1994-07-30 12:58:42 -0400
commit67a3773731b8a4f7a6f4f69e67d4b7ef69296136 (patch)
tree88c52a751c27dd41d2a6c69b4ce11096be18ff91 /gcc/cse.c
parent96c9d70dda35cd5901c6905172c44e472d49dc21 (diff)
downloadgcc-67a3773731b8a4f7a6f4f69e67d4b7ef69296136.tar.gz
(fold_rtx, case MEM): Surround TRUNCATE for jump table entry with a CONST.
(fold_rtx, case '1'): Handle operand 0 of a CONST. (fold_rtx, case PLUS): Handle (const (minus (label_ref) (label_ref))). From-SVN: r7832
Diffstat (limited to 'gcc/cse.c')
-rw-r--r--gcc/cse.c40
1 files changed, 32 insertions, 8 deletions
diff --git a/gcc/cse.c b/gcc/cse.c
index b4947d04c50..adc99329407 100644
--- a/gcc/cse.c
+++ b/gcc/cse.c
@@ -5001,7 +5001,11 @@ fold_rtx (x, insn)
if (GET_MODE (table) != Pmode)
new = gen_rtx (TRUNCATE, GET_MODE (table), new);
- return new;
+ /* Indicate this is a constant. This isn't a
+ valid form of CONST, but it will only be used
+ to fold the next insns and then discarded, so
+ it should be safe. */
+ return gen_rtx (CONST, GET_MODE (new), new);
}
}
}
@@ -5174,13 +5178,26 @@ fold_rtx (x, insn)
switch (GET_RTX_CLASS (code))
{
case '1':
- /* We can't simplify extension ops unless we know the original mode. */
- if ((code == ZERO_EXTEND || code == SIGN_EXTEND)
- && mode_arg0 == VOIDmode)
- break;
- new = simplify_unary_operation (code, mode,
- const_arg0 ? const_arg0 : folded_arg0,
- mode_arg0);
+ {
+ int is_const = 0;
+
+ /* We can't simplify extension ops unless we know the
+ original mode. */
+ if ((code == ZERO_EXTEND || code == SIGN_EXTEND)
+ && mode_arg0 == VOIDmode)
+ break;
+
+ /* If we had a CONST, strip it off and put it back later if we
+ fold. */
+ if (const_arg0 != 0 && GET_CODE (const_arg0) == CONST)
+ is_const = 1, const_arg0 = XEXP (const_arg0, 0);
+
+ new = simplify_unary_operation (code, mode,
+ const_arg0 ? const_arg0 : folded_arg0,
+ mode_arg0);
+ if (new != 0 && is_const)
+ new = gen_rtx (CONST, mode, new);
+ }
break;
case '<':
@@ -5358,6 +5375,13 @@ fold_rtx (x, insn)
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
+ && 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);
}
/* If second operand is a register equivalent to a negative