Re: Re: help : likely

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

 



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.

regards

Mulyadi

--
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