problem about branch-prediction-Collection of common programming errors
Brian Vandenberg
assembly pipeline branch-prediction
updatedChanged the 2nd line of assembly to the mnemonic actually being used (mflr) and added more info at the bottom.I ran across some code (using gcc) resembling the following (paraphrased):#define SOME_MACRO( someVar ) \ do { \__asm__ ( \” b 0f\n” \”0: mflr %0\n” \: “=r”( someVar ) \); \ } while(0)… where the b instruction (ppc) is a short jmp and mflr is getting the contents of the ‘link r
marshall
optimization assembly compiler branch-prediction pentium
On a modern Pentium it is no longer possible to give branching hints to the processor it seems. Assuming that a profiling compiler such as gcc with profile-guided optimization gains information about likely branching behavior, what can it do to produce code that will execute more quickly?The only option I know of is to move unlikely branches to the end of a function. Is there anything else?Update.http://download.intel.com/products/processor/manual/325462.pdf volume 2a, section 2.1.1 says”Branch
Web site is in building