summaryrefslogtreecommitdiff
path: root/gcc/regmove.c
diff options
context:
space:
mode:
authorlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>1998-08-22 23:21:24 +0000
committerlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>1998-08-22 23:21:24 +0000
commit997026ee2a790b76ac18d477b54c188c856ae303 (patch)
tree6e6ec836aedf9ef4467ecc2d2415fd0259f4e746 /gcc/regmove.c
parent0a7a3b35580053aa62e93a01cb8ce4cc048aa10d (diff)
downloadgcc-997026ee2a790b76ac18d477b54c188c856ae303.tar.gz
* recog.c (validate_replace_rtx_group): New function. * recog.h (validate_replace_rtx_group): Declare it. * regmove.c (optimize_reg_copy_3): If any substitution fails, then undo the entire group of substitutions. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@21910 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/regmove.c')
-rw-r--r--gcc/regmove.c31
1 files changed, 20 insertions, 11 deletions
diff --git a/gcc/regmove.c b/gcc/regmove.c
index 089dc46e8a7..b4f7b6dd1bc 100644
--- a/gcc/regmove.c
+++ b/gcc/regmove.c
@@ -549,23 +549,32 @@ optimize_reg_copy_3 (insn, dest, src)
old_mode = GET_MODE (src_reg);
PUT_MODE (src_reg, GET_MODE (src));
XEXP (src, 0) = SET_SRC (set);
- if (! validate_change (p, &SET_SRC (set), src, 0))
- {
- PUT_MODE (src_reg, old_mode);
- XEXP (src, 0) = src_reg;
- return;
- }
+
+ /* Include this change in the group so that it's easily undone if
+ one of the changes in the group is invalid. */
+ validate_change (p, &SET_SRC (set), src, 1);
+
+ /* Now walk forward making additional replacements. We want to be able
+ to undo all the changes if a later substitution fails. */
subreg = gen_rtx_SUBREG (old_mode, src_reg, 0);
while (p = NEXT_INSN (p), p != insn)
{
if (GET_RTX_CLASS (GET_CODE (p)) != 'i')
continue;
- /* If we can not perform the replacement, then abort now
- to make debugging easier. */
- if (! validate_replace_rtx (src_reg, subreg, p))
- abort ();
+
+ /* Make a tenative change. */
+ validate_replace_rtx_group (src_reg, subreg, p);
+ }
+
+ validate_replace_rtx_group (src, src_reg, insn);
+
+ /* Now see if all the changes are valid. */
+ if (! apply_change_group ())
+ {
+ /* One or more changes were no good. Back out everything. */
+ PUT_MODE (src_reg, old_mode);
+ XEXP (src, 0) = src_reg;
}
- validate_replace_rtx (src, src_reg, insn);
}