https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112844

--- Comment #5 from Drea Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Petr Skocik from comment #4)
> (In reply to Jakub Jelinek from comment #1)
> > With -Os you ask the code to be small.  So, while internally the hint is
> > still present in edge probabilities, -Os is considered more important and
> > certain code changes based on the probabilities aren't done if they are
> > known or expected to result in larger code.
> 
> I think this approach is abit problematic because
> (a) it fails to deliver the promised smaller code
> e.g., the following
> 
> void fn(void);
> void maybefn(int X){ if(__builtin_expect(X,0)) fn(); }
> 
> under gcc -Os codegens
> 
> maybefn:
>         testl   %edi, %edi
>         je      .L1
>         jmp     fn
> .L1:
>         ret
> 
> which is 1-jmp-larger than what you'd get if the compiler followed the hint
> (clang's codegen):
> 
> maybefn:
>         test    edi, edi
>         jne     fn@PLT
>         ret
> 

That is recorded as PR 47253 and a patch for review was submitted just
recently.

Reply via email to