This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Propagate profile counts during switch expansion


> On Sun, Oct 14, 2012 at 8:09 AM, Jan Hubicka <hubicka@ucw.cz> wrote:
> > Hi,
> >
> > Index: optabs.c
> > ===================================================================
> > --- optabs.c    (revision 191879)
> > +++ optabs.c    (working copy)
> > @@ -4249,7 +4249,7 @@ prepare_operand (enum insn_code icode, rtx x, int
> >     we can do the branch.  */
> >
> >  static void
> > -emit_cmp_and_jump_insn_1 (rtx test, enum machine_mode mode, rtx label)
> > +emit_cmp_and_jump_insn_1 (rtx test, enum machine_mode mode, rtx label, int prob)
> >  {
> >    enum machine_mode optab_mode;
> >    enum mode_class mclass;
> > @@ -4261,7 +4261,16 @@ static void
> >
> >    gcc_assert (icode != CODE_FOR_nothing);
> >    gcc_assert (insn_operand_matches (icode, 0, test));
> > -  emit_jump_insn (GEN_FCN (icode) (test, XEXP (test, 0), XEXP (test, 1), label));
> > +  rtx insn = emit_insn (
> > +      GEN_FCN (icode) (test, XEXP (test, 0), XEXP (test, 1), label));
> >
> > I think we did not change to style of mixing declaration and code yet.  So
> > please put declaration ahead.
> Ok.
> 
> >
> > I think you want to keep emit_jump_insn.  Also do nothing when profile_status
> > == PROFILE_ABSENT.
> 
> Why should this be dependent on profile_status? The PROB passed could
> also come from static prediction right.

In that case profile_status is PROFILE_GUESSED.
> I think this should work:
> 
> -  if (single_succ_p (b))
> +  else if (single_succ_p (b))
>      {
>        e = single_succ_edge (b);
>        e->probability = REG_BR_PROB_BASE;
>        e->count = b->count;
>        return;
>      }
> -  guess_outgoing_edge_probabilities (b);
> +  else
> +    {
> +      /* We rely on BBs with more than two successors to have sane
> probabilities
> +         and do not guess them here. For BBs terminated by switch statements
> +         expanded to jump-table jump, we have done the right thing during
> +         expansion. For EH edges, we still guess the probabilities here.  */
> +      bool complex_edge = false;
> +      FOR_EACH_EDGE (e, ei, b->succs)
> +        if (e->flags & EDGE_COMPLEX)
> +          {
> +            complex_edge = true;
> +            break;
> +          }
> +      if (complex_edge)
> +        guess_outgoing_edge_probabilities (b);
> +    }
> +

 OK.

Honza


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]