linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* Question : about difference with bdnz and bdnz+
@ 2009-08-27  5:04 HongWoo Lee
  2009-08-27  9:30 ` Benjamin Herrenschmidt
  0 siblings, 1 reply; 2+ messages in thread
From: HongWoo Lee @ 2009-08-27  5:04 UTC (permalink / raw)
  To: linuxppc-dev

Hi ~

I found the code in the linux kernel.

static __inline__ void clear_page(void *addr)
{
    unsigned long lines, line_size;
    line_size = cpu_caches.dline_size;
    lines = cpu_caches.dlines_per_page;

    __asm__ __volatile__(
            "mtctr  %1      # clear_page\n\
            1:  dcbz    0,%0\n\
            add     %0,%0,%3\n\
            bdnz+   1b"
            : "=r" (addr)
            : "r" (lines), "0" (addr), "r" (line_size)
            : "ctr", "memory");
}

And I have a question about bdnz+ instruction.
Through googling, I learned that bdnz does decrement count register and 
branch if it is still nonzero.
But I couldn't find what "bdnz+" is.
Can anybody explain to me what it is ??

Thanks in advance.

HongWoo.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Question : about difference with bdnz and bdnz+
  2009-08-27  5:04 Question : about difference with bdnz and bdnz+ HongWoo Lee
@ 2009-08-27  9:30 ` Benjamin Herrenschmidt
  0 siblings, 0 replies; 2+ messages in thread
From: Benjamin Herrenschmidt @ 2009-08-27  9:30 UTC (permalink / raw)
  To: HongWoo Lee; +Cc: linuxppc-dev

On Thu, 2009-08-27 at 14:04 +0900, HongWoo Lee wrote:
> And I have a question about bdnz+ instruction.
> Through googling, I learned that bdnz does decrement count register
> and 
> branch if it is still nonzero.
> But I couldn't find what "bdnz+" is.
> Can anybody explain to me what it is ??

On PowerPC, branch instructions can have a "hint" (+ or - added to the
mnemonic) which indicates to the processor whether the branch is likely
to be taken or not, and overrides the dynamic branch prediction.

In most case, it's not necessary though I suppose in the case at hand,
we are pretty confident that we're going to loop a lot more times than
exit from the loop so it won't hurt to put the hint in there.

Note that there have been subtle changes in the way those hints work
between earlier and modern PowerPC processors and the way they are
encoded will be different depending on what CPU you are building for,
but that's an entirely different headache :-)

Cheers,
Ben.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-08-27  9:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-27  5:04 Question : about difference with bdnz and bdnz+ HongWoo Lee
2009-08-27  9:30 ` Benjamin Herrenschmidt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).