This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Gimplify builtin_expect on short-circuiting conditionals
Paolo Bonzini writes:
> Adam Nemet wrote:
> > The gimplifier treats __builtin_expect as a regular function call.
> > This does not seem to work well if the argument is a logical
> > expression with short-circuit semantics.
>
> This is PR21513:
>
> http://gcc.gnu.org/ml/gcc-bugs/2005-12/msg01775.html
I also thought of doing this in fold_builtin_expect but then I
convinced myself that folding in the call expression is too late for
shortcutting so we need to look ahead. I of course forgot about the
folding in the front-end. I quickly tried and adding the
transformation into fold seems to achieve the same thing so I will
reimplement the patch along your ideas. Thanks.
Adam