[PATCH] cse (canon_reg): Don't modify insns without using validate_change
Andreas Krebbel
krebbel1@de.ibm.com
Tue May 30 13:43:00 GMT 2006
Hi,
> In your previous mail you mentioned the need to call apply_change_group
> after canon_reg; I see places in cse.c where that isn't done. Why don't
> we need to change them?
The cases I was concerned about where cases where either INSN is NULL_RTX
or apply_change_group is called later on. According to the comment above
canon_reg the function must not call validate_change if INSN isn't set.
That's why I've left the check for INSN != 0 in validate_canon_reg. It
should be ok with this.
> Also, the comment at the top of canon_reg seems out of date with this
> change.
Ok, comment adjusted.
2006-05-30 Andreas Krebbel <krebbel1@de.ibm.com>
* cse.c (validate_canon_reg, cse_insn): Don't change insns without
calling recog.
Index: gcc/cse.c
===================================================================
*** gcc/cse.c.orig 2006-05-29 15:28:11.000000000 +0200
--- gcc/cse.c 2006-05-30 14:04:58.000000000 +0200
*************** static void
*** 2728,2744 ****
validate_canon_reg (rtx *xloc, rtx insn)
{
rtx new = canon_reg (*xloc, insn);
- int insn_code;
/* If replacing pseudo with hard reg or vice versa, ensure the
insn remains valid. Likewise if the insn has MATCH_DUPs. */
! if (insn != 0 && new != 0
! && REG_P (new) && REG_P (*xloc)
! && (((REGNO (new) < FIRST_PSEUDO_REGISTER)
! != (REGNO (*xloc) < FIRST_PSEUDO_REGISTER))
! || GET_MODE (new) != GET_MODE (*xloc)
! || (insn_code = recog_memoized (insn)) < 0
! || insn_data[insn_code].n_dups > 0))
validate_change (insn, xloc, new, 1);
else
*xloc = new;
--- 2728,2737 ----
validate_canon_reg (rtx *xloc, rtx insn)
{
rtx new = canon_reg (*xloc, insn);
/* If replacing pseudo with hard reg or vice versa, ensure the
insn remains valid. Likewise if the insn has MATCH_DUPs. */
! if (insn != 0 && new != 0)
validate_change (insn, xloc, new, 1);
else
*xloc = new;
*************** validate_canon_reg (rtx *xloc, rtx insn)
*** 2748,2755 ****
replace each register reference inside it
with the "oldest" equivalent register.
! If INSN is nonzero and we are replacing a pseudo with a hard register
! or vice versa, validate_change is used to ensure that INSN remains valid
after we make our substitution. The calls are made with IN_GROUP nonzero
so apply_change_group must be called upon the outermost return from this
function (unless INSN is zero). The result of apply_change_group can
--- 2741,2747 ----
replace each register reference inside it
with the "oldest" equivalent register.
! If INSN is nonzero validate_change is used to ensure that INSN remains valid
after we make our substitution. The calls are made with IN_GROUP nonzero
so apply_change_group must be called upon the outermost return from this
function (unless INSN is zero). The result of apply_change_group can
*************** cse_insn (rtx insn, rtx libcall_insn)
*** 4943,4959 ****
rtx dest = SET_DEST (sets[i].rtl);
rtx src = SET_SRC (sets[i].rtl);
rtx new = canon_reg (src, insn);
- int insn_code;
sets[i].orig_src = src;
! if ((REG_P (new) && REG_P (src)
! && ((REGNO (new) < FIRST_PSEUDO_REGISTER)
! != (REGNO (src) < FIRST_PSEUDO_REGISTER)))
! || (insn_code = recog_memoized (insn)) < 0
! || insn_data[insn_code].n_dups > 0)
! validate_change (insn, &SET_SRC (sets[i].rtl), new, 1);
! else
! SET_SRC (sets[i].rtl) = new;
if (GET_CODE (dest) == ZERO_EXTRACT)
{
--- 4935,4943 ----
rtx dest = SET_DEST (sets[i].rtl);
rtx src = SET_SRC (sets[i].rtl);
rtx new = canon_reg (src, insn);
sets[i].orig_src = src;
! validate_change (insn, &SET_SRC (sets[i].rtl), new, 1);
if (GET_CODE (dest) == ZERO_EXTRACT)
{
More information about the Gcc-patches
mailing list