From e757da5ef3e07c518620a35cbba35b5ac656fdcc Mon Sep 17 00:00:00 2001 From: Jeff Law Date: Sat, 22 Aug 1998 17:21:24 -0600 Subject: [PATCH] recog.c (validate_replace_rtx_group): New function. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit � * 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. From-SVN: r21910 --- gcc/recog.h | 1 + gcc/regmove.c | 31 ++++++++++++++++++++----------- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/gcc/recog.h b/gcc/recog.h index 6e6bb064824..980b76f70d7 100644 --- a/gcc/recog.h +++ b/gcc/recog.h @@ -32,6 +32,7 @@ extern int constrain_operands PROTO((int, int)); extern int memory_address_p PROTO((enum machine_mode, rtx)); extern int strict_memory_address_p PROTO((enum machine_mode, rtx)); extern int validate_replace_rtx PROTO((rtx, rtx, rtx)); +extern void validate_replace_rtx_group PROTO((rtx, rtx, rtx)); extern int validate_replace_src PROTO((rtx, rtx, rtx)); extern int reg_fits_class_p PROTO((rtx, enum reg_class, int, enum machine_mode)); 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); }