Re: Re: help : likely

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 8/31/05, Mulyadi Santosa <mulyadi.santosa@xxxxxxxxx> wrote:
> Hello :)
> 
> > I'm not sure I clearly understand your question.
> >
> > When you do :
> >
> >  if (likely(something)) {
> >     ...we-do-something-if true
> >  }
> 
> Let me try to rephrase my questions :) yes, I understand that likely()
> will optimize the branch which we will likely taken. But here I am
> focusing on the assembly code generated by the gcc itself...
> 
> From the C code you have written to illustrate likely() and the result
> of objdump -S, I got conclusion that the optimization is done by
> arranging the code (the assembler output of we-do-something-if-true)
> directly following the "cmp" and "jne" instruction. This way, the
> processor will execute the next instruction faster because it is
> already prefetched at L1 cache and "jump" is avoided since it is a bit
> costly . I am not sure on what you mean by "pipeline", so I guess you
> mean CPU pipeline. Please CMIIW and I am sorry if I bring confusion
> here.

As far as i cud understand, compiler places the if part after the cmp
instruction if we used likely(), because if part has more probabilty
to execution. On other hand, if we used unlikely(), compiler places
else part after cmp instruction as we have less probability of if part
to be execued, this means more probability of else part to be executed
.... dont get this confused ;-)

yes I think, by pipeline he means the instruction cache.

-Gaurav

> 
> regards
> 
> Mulyadi
> 
> --
> Kernelnewbies: Help each other learn about the Linux kernel.
> Archive:       http://mail.nl.linux.org/kernelnewbies/
> FAQ:           http://kernelnewbies.org/faq/
> 
>

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux