[PATCH, GCC, stage1] Fallback to copy-prop if constant-prop not possible
Thomas Preud'homme
thomas.preudhomme@arm.com
Tue Feb 17 02:51:00 GMT 2015
> From: Steven Bosscher [mailto:stevenb.gcc@gmail.com]
> Sent: Tuesday, February 17, 2015 4:19 AM
> To: Thomas Preud'homme
> Cc: GCC Patches; Richard Biener
> Subject: Re: [PATCH, GCC, stage1] Fallback to copy-prop if constant-prop
> not possible
>
> 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()).
Ack.
>
>
> > @@ -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()).
I'm not sure I follow you here. First, it seems to me that the equivalent
test is rather REG_P && !HARD_REGISTER_P since here it checks if it's
a pseudo register.
Then, do you mean the test can be simply removed because of the
REG_P && !HARD_REGISTER_P in hash_scan_set () called indirectly by
compute_hash_table () when called in one_cprop_pass () before any
cprop_insn ()? Or do you mean I should move the check in
find_avail_set ()?
Best regards,
Thomas
More information about the Gcc-patches
mailing list