linux-mips
[Top] [All Lists]

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

To: Manuel Lauss <mano@roarinelk.homelinux.net>
Subject: Re: [PATCH v2] Alchemy: cpu feature override constants.
From: Ralf Baechle <ralf@linux-mips.org>
Date: Wed, 26 Nov 2008 08:34:35 +0000
Cc: David Daney <ddaney@caviumnetworks.com>, LMO <linux-mips@linux-mips.org>
In-reply-to: <20081126080808.GA13230@roarinelk.homelinux.net>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <20081125231230.GA10366@roarinelk.homelinux.net> <492C8904.5040202@caviumnetworks.com> <20081126055053.GA12831@roarinelk.homelinux.net> <20081126075103.GA4232@linux-mips.org> <20081126080808.GA13230@roarinelk.homelinux.net>
Sender: linux-mips-bounce@linux-mips.org
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.

  Ralf

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