https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67755
Bug ID: 67755 Summary: Bad edge probability/block freqency for tree jump threading Product: gcc Version: 5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: pthaugen at gcc dot gnu.org CC: bergner at gcc dot gnu.org, dje at gcc dot gnu.org, tejohnson at google dot com Target Milestone: --- Host: powerpc64-unknown-linux-gnu Target: powerpc64-unknown-linux-gnu Build: powerpc64-unknown-linux-gnu Noticed a problem where static branch hint was being applied to a branch resulting in performance degradation, bisected change to r215739. Reduced to following testcase, compiled with "-S -m64 -O1". void (*zend_block_interruptions) (void); int * _zend_mm_alloc_int (int * heap, long int size) { int *best_fit; long int true_size = (size < 15 ? 32 : size); if (zend_block_interruptions) zend_block_interruptions (); if (__builtin_expect ((true_size < 543), 1)) best_fit = heap + 2; else best_fit = heap; return best_fit; } For the snippet of code: if (zend_block_interruptions) zend_block_interruptions (); 094t.copyrename3 dump shows probability of 69.8%/30.2% (true/false) for the function pointer <> null test. After jump threading, 095t.dom1 shows probability of 100%/0% for the original block and 39.7%/60.3% for the duplicated block. The original block is then statically predicted since it has 100% probability. Also note that the probabilities for the duplicated block have approx been reversed, which also seems wrong.