This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug middle-end/59521] __builtin_expect not effective in switch


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.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]