Re: Immediate values

Mathieu Desnoyers
2009-09-24T14:15:59Z

* Jason Baron (jbaron@redhat.com) wrote:
> On Thu, Sep 24, 2009 at 02:34:28PM +0200, Ingo Molnar wrote:
> > * Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca> wrote:
> >
> > > Hi Ingo,
> > >
> > > Andi asked me this week when we should expect to see the "immediate
> > > values" make it into mainline. I remember you pulled them at one
> > > point. He would like to use them to encode some very hot-path
> > > variables into the instruction stream.
> > >
> > > How should I proceed to get that upstream ? Would a repost be
> > > appropriate ?
> >
> > Would have to see it in full context i guess, with before/after
> > measurements, etc.
> >
> > Ingo
>
> right we've proposed an alternative to the immediate values, which I've
> been calling 'jump label', here:
>
> http://marc.info/?l=linux-kernel&m=125200966226921&w=2
>
> The basic idea is that gcc, 4.5 will have support for an 'asm goto'
> construct which can refer to c code labels. Thus, we can replace a nop
> in the code stream with a 'jmp' instruction to various branch targets.
>
> In terms of a comparison between the two, IMO, I think that the syntax
> for the immediate variables can be more readable, since it just looks
> like a conditional expression.
>
> The immediate values do a 'mov', 'test' and then a jump, whereas jump
> label can just do a jump. So in this respect, I believe jump label can
> be more optimal. Additinally, if we want to mark sections 'cold' so they
> don't impact the istruction cache, the jump label already has the labels
> for doing so. Obviously, a performance comparison would be interesting
> as well.
>

For branches, I'm convinced that a "static jump" approach will beat
immediate values anytime, because you save the BPB hit completely.

However, there are other use-cases involving a variable read, and in
that case immediate values are useful. Andi has been bugging me for a
while to re-post this patchset, I'm pretty sure he has precise ideas
about how he would like to use it.

Until we get the static jump support mainlined in gcc, immediate values
at least save the d-cache hit. So it would be a step in the right
direction.

Thanks,

Mathieu

> thanks,
>
> -Jason
>
>

--
Mathieu Desnoyers
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68