This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH, GCC, stage1] Fallback to copy-prop if constant-prop not possible
- From: Steven Bosscher <stevenb dot gcc at gmail dot com>
- To: "Thomas Preud'homme" <thomas dot preudhomme at arm dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>, Richard Biener <rguenther at suse dot de>
- Date: Mon, 16 Feb 2015 21:19:17 +0100
- Subject: Re: [PATCH, GCC, stage1] Fallback to copy-prop if constant-prop not possible
- Authentication-results: sourceware.org; auth=none
- References: <000501d049d3$079385a0$16ba90e0$ at arm dot com>
On Mon, Feb 16, 2015 at 11:26 AM, Thomas Preud'homme wrote:
> /* Subroutine of cprop_insn that tries to propagate constants into
> @@ -1044,40 +1042,41 @@ cprop_insn (rtx_insn *insn)
> - /* Constant propagation. */
> - if (cprop_constant_p (src))
> - {
> - if (constprop_register (reg_used, src, insn))
> + /* Constant propagation. */
> + if (src_cst && cprop_constant_p (src_cst)
> + && constprop_register (reg_used, src_cst, insn))
> {
> changed_this_round = changed = 1;
> global_const_prop_count++;
The cprop_constant_p test is redundant, you only have non-NULL src_cst
if it is a cprop_constant_p (as you test for it in find_avail_set()).
> @@ -1087,18 +1086,16 @@ retry:
> "GLOBAL CONST-PROP: Replacing reg %d in ", regno);
> fprintf (dump_file, "insn %d with constant ",
> INSN_UID (insn));
> - print_rtl (dump_file, src);
> + print_rtl (dump_file, src_cst);
> fprintf (dump_file, "\n");
> }
> if (insn->deleted ())
> return 1;
> }
> - }
> - else if (REG_P (src)
> - && REGNO (src) >= FIRST_PSEUDO_REGISTER
> - && REGNO (src) != regno)
> - {
> - if (try_replace_reg (reg_used, src, insn))
> + else if (src_reg && REG_P (src_reg)
> + && REGNO (src_reg) >= FIRST_PSEUDO_REGISTER
> + && REGNO (src_reg) != regno
> + && try_replace_reg (reg_used, src_reg, insn))
Likewise for the REG_P and ">= FIRST_PSEUDO_REGISTER" tests here (with
the equivalent and IMHO preferable HARD_REGISTER_P test in
find_avail_set()).
Looks good to me otherwise.
Ciao!
Steven