[Bug middle-end/59521] __builtin_expect not effective in switch
marxin at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Fri Jul 14 12:17:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59521
--- Comment #11 from Martin Liška <marxin at gcc dot gnu.org> ---
(In reply to Yuri Gribov from comment #10)
> (In reply to Martin Liška from comment #9)
> > The patch works for me for the described case, but does not for PGO, which
> > should do the same based on real numbers:
>
> Problem here is that we optimize only very_likely edges. They requires
> 99.95% probability whereas in your testcase we only get 90%. Changing mods
> to "% 10000" and "% 1000000" results in desired asm:
>
> cmpl $1, %eax
> je .L3
> cmpl $10, %eax
> je .L4
> cmpl $100, %eax
> je .L5
Maybe I miss something, but I would expect to sort all branches in
emit_case_decision_tree as either predictors can sort branches, or one have a
profile feedback. Having a chain of equal comparisons, that should be always
beneficial, or?
>
> > Just a small note, Honza's planning to rewrite switch expansion to happen on
> > tree level. Maybe (hopefully) such transformations
> > will be easier on tree level?
>
> Thanks, that's important to consider. I'll send patch for review and Cc him
> to maybe comment. Probly I'll just rebase when his work is in.
Actually he was convincing me to rewrite it, but I still have more unfinished
tasks from history which I should start with ;)
More information about the Gcc-bugs
mailing list