[Top] [All Lists]

Re: [PATCH v2] Alchemy: cpu feature override constants.

To: Manuel Lauss <>
Subject: Re: [PATCH v2] Alchemy: cpu feature override constants.
From: Ralf Baechle <>
Date: Wed, 26 Nov 2008 08:34:35 +0000
Cc: David Daney <>, LMO <>
In-reply-to: <>
Original-recipient: rfc822;
References: <> <> <> <> <>
User-agent: Mutt/1.5.18 (2008-05-17)
On Wed, Nov 26, 2008 at 09:08:08AM +0100, Manuel Lauss wrote:

> > then be able to use constant propagation and dead code elemination to
> > optimize the code for a particular target system.
> > 
> > The way fls() is written it will only use of CLZ if the expression
> > cpu_has_mips_r is a constant, that is if the kernel is being built
> > exclusivly for MIPS32 / MIPS64 revision 1 or higher.  The reason that
> Ah, so the __builtin_constat_p() is a compiletime check as to whether a
> given symbol is a constant or needs to be evaluated at runtime?  That
> explains a lot.

Yes.  See GCC documentation.  It's used all over place in the kernel for
optimizations.  In some occasions gcc is not able to determine the
constness of an expression, so the code should better prepared to handle
a 0 return value.  Another interesting property of __buitin_const_p() is
that side effects don't matter, that is for example

  __buitin_const_p(expr) && (expr)

will only execute any sideeffects the expression expr may have once which
is extremly handy in macro.


<Prev in Thread] Current Thread [Next in Thread>