This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/59521] __builtin_expect not effective in switch
- From: "tetra2005 at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 14 Jul 2017 12:13:36 +0000
- Subject: [Bug middle-end/59521] __builtin_expect not effective in switch
- Auto-submitted: auto-generated
- References: <bug-59521-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59521
--- Comment #10 from Yuri Gribov <tetra2005 at gmail dot com> ---
(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
> 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.