> 
> Hello.
> 
> Maybe a silly question, but isn't the code only an obfuscation?
> What about doing:
> 
> if (__builtin_constant_p(x))
>   return x < 2 ? 0 : __builtin_clz(x);
> 
> which is fully eliminated in a c.031t.ccp1 pass right after einline happens
> for a call context where 'x' is a constant.
> 
> Isn't the right place for fix in Linux kernel?

Yes, Linux kernel should be fixed and that is discussed in the
corresponding PR (there is also correct replacement for that log1
function suggested already).

However there are many additional examples of similar inline functions
doing (ab)use of builtin_constant_p (and not all of them translating to
an existing gcc builtin). So adding a heuristics seems useful (since it
is quite reliable heuristics I would say). Also in the context of
decreasing the -O2 inliner defaults in gcc10 I think number of such
inliner became unlucky and are no longer inlined as expected (a problem
I did not realize until looking into the PR)

Honza
> 
> Martin

Reply via email to