(original) (raw)
Hi Martin,
Your observation is correct. The corresponding code is next:
� float infrequent\_prob = PROB\_UNLIKELY\_MAG(3); // 0.001
� // BlockLayoutByFrequency optimization moves infrequent branch
� // from hot path. No point in CMOV'ing in such case (110 is used
� // instead of 100 to take into account not exactness of float value).
� if (BlockLayoutByFrequency) {
� � infrequent\_prob = MAX2(infrequent\_prob, (float)BlockLayoutMinDiamondPercentage/110.0f);
� }
� // Check for highly predictable branch. �No point in CMOV'ing if
� // we are going to predict accurately all the time.
� if (iff->\_prob < infrequent\_prob ||
� � � iff->\_prob > (1.0f - infrequent\_prob))
� � return NULL;
Note, BlockLayoutMinDiamondPercentage is default 20 so infrequent\_prob become 0.2 as you observed.
C2 moves infrequent code outside the loop (with branches out and back) to keep only hot code inside.
It looks like it does not happen in your case and I need to look why. There are several conditions besides BlockLayoutByFrequency and the above code could be incorrect and needs to be fixed (or removed).