------- Comment #8 from jakub at gcc dot gnu dot org 2010-02-18 12:47 ------- Created an attachment (id=19906) --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=19906&action=view) gcc45-pr42233.patch
The reason why it behaves differently with __builtin_expect from normal condition is that in the latter case gimple_boolify changes the types of the comparisons etc. to _Bool, while for __builtin_expect it doesn't recurse into its first argument. The attached patch fixes that. Then we are back to the 4.3 generated code, i.e. the same as is generated without __builtin_expect. At this point the problem is described in a comment above add_reg_br_prob_note: /* Verify that there is exactly single jump instruction since last and attach REG_BR_PROB note specifying probability. ??? We really ought to pass the probability down to RTL expanders and let it re-distribute it when the conditional expands into multiple conditionals. This is however difficult to do. */ Since here there are two jumps, not one, no REG_BR_PROB note is added. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42233