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: PATCH: Pad short functions for Atom


> > I don't think you need saving. ?Exit block has as predecestor all return blocks
> > and we don't have duplicated edges in CFG.
> 
> Without it, I ran into loops which turn this into infinite recursive call.
> Is there a way to terminate loop?

Yes, I only later noticed you are walking backwards the CFG.
> 
> >> +
> >> + ?BLOCK_INFO (bb)->done = true;
> >> +
> >> + ?/* Count number of instructions in this block. ?Return 4 if the number
> >> + ? ? of instructions >= 4. ?*/
> >> + ?insn_count = 0;
> >
> > Hmm, if NOP counts as half of instructions, it is really cycle count rather than
> > insn count, right? ?Isn't our DFA API simple to use enough so we can actually
> > use it to get cycle count of BB?
> 
> I want cycle counts. I looked at DFA.  I couldn't find an easy way to
> use it.  Are
> there any examples?

I guess you will need to look into scheduler.  If I remember correctly DFA provides basically
capabilities to answer question "can I insert this insn in current cycle" and "advance cycle"
so combining those should give you cycle count.
> 
> >> +
> >> + ?/* This block has less than 4 instructions. ?Count all predecessor
> >> + ? ? edges of this block. ?*/
> >> + ?pred_insn_count = 0;
> >> + ?FOR_EACH_EDGE (e, ei, bb->preds)
> >> + ? ?{
> >> + ? ? ?int count = ix86_count_insn (e->src);
> >> + ? ? ?if (pred_insn_count == 0)
> >> + ? ? pred_insn_count = count;
> >> + ? ? ?else if (count < pred_insn_count)
> >> + ? ? pred_insn_count = count;
> >> + ? ?}
> >> +
> >> + ?BLOCK_INFO (bb)->value = pred_insn_count + insn_count;
> >> + ?return pred_insn_count + insn_count;
> >
> > Ahh, you are actually trying to compute hot path through the function leading to the return
> > statement. ?I think you really want to use profile info here.
> 
> That is a good idea. Are there any examples I can look at?

I would just try to compute in what probability program arrives to the return BB when
return value is not ready yet.  Basically you get recursive function:

walk_bb (BB, time, probability)

where time is amount of cycles you took to reach to BB, probability is probability that you
get there.

walk_bb will bail out if probability is too small so we don't care or time
is over 4 cycles.
When this does not happen, it will walk the BB, compute time it takes and if it has return BB
and time is too small it could decide to insert nops.  if it reach conditional at the end it
recursively calls itself on both branches with combining the probability it has with probability
of the edge...

and then call walk_bb (ENTRY_BLOCK_PTR, 0, REG_BR_PROB_BASE)...

Honza
> 
> > Otherwise the patch seems resonable...
> >
> 
> Thanks.
> 
> -- 
> H.J.


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