From: Richard Sandiford Date: Wed, 28 Jul 2004 19:33:10 +0000 (+0000) Subject: cse.c (validate_canon_reg): New function, split out from... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=eef3c949614ae3fdea4b3f375107d8562f1d287d;p=gcc.git cse.c (validate_canon_reg): New function, split out from... * cse.c (validate_canon_reg): New function, split out from... (canon_reg): ...here. Use validate_canon_reg for both 'e' and 'E'. From-SVN: r85270 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7341996e85e..9e3f1b817c7 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2004-07-28 Richard Sandiford + + * cse.c (validate_canon_reg): New function, split out from... + (canon_reg): ...here. Use validate_canon_reg for both 'e' and 'E'. + 2004-07-28 Diego Novillo * tree-ssa-alias.c (maybe_create_global_var): Don't just diff --git a/gcc/cse.c b/gcc/cse.c index 3d08ff0777c..6880787f4c5 100644 --- a/gcc/cse.c +++ b/gcc/cse.c @@ -2626,6 +2626,29 @@ cse_rtx_varies_p (rtx x, int from_alias) return rtx_varies_p (x, from_alias); } +/* Subroutine of canon_reg. Pass *XLOC through canon_reg, and validate + the result if necessary. INSN is as for canon_reg. */ + +static void +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; +} + /* Canonicalize an expression: replace each register reference inside it with the "oldest" equivalent register. @@ -2695,25 +2718,10 @@ canon_reg (rtx x, rtx insn) int j; if (fmt[i] == 'e') - { - rtx new = canon_reg (XEXP (x, i), 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 (XEXP (x, i)) - && (((REGNO (new) < FIRST_PSEUDO_REGISTER) - != (REGNO (XEXP (x, i)) < FIRST_PSEUDO_REGISTER)) - || (insn_code = recog_memoized (insn)) < 0 - || insn_data[insn_code].n_dups > 0)) - validate_change (insn, &XEXP (x, i), new, 1); - else - XEXP (x, i) = new; - } + validate_canon_reg (&XEXP (x, i), insn); else if (fmt[i] == 'E') for (j = 0; j < XVECLEN (x, i); j++) - XVECEXP (x, i, j) = canon_reg (XVECEXP (x, i, j), insn); + validate_canon_reg (&XVECEXP (x, i, j), insn); } return x;