[PATCH V4 1/2] arm: mm: Introduce {pte,pmd}_isset and {pte,pmd}_isclear

Russell King - ARM Linux linux at arm.linux.org.uk
Fri Jun 20 03:04:58 PDT 2014


On Fri, Jun 20, 2014 at 10:12:26AM +0100, Will Deacon wrote:
> On Mon, Jun 16, 2014 at 03:32:38PM +0100, Steve Capper wrote:
> > -#define pmd_young(pmd)		(pmd_val(pmd) & PMD_SECT_AF)
> > +#define pmd_isset(pmd, val)	((u32)(val) == (val) ? pmd_val(pmd) & (val) \
> > +						: !!(pmd_val(pmd) & (val)))
> 
> What does GCC generate for this as opposed to an unconditional !!?

For any constant "val", the result of (u32)(val) == (val) is also a
constant, so GCC should evaluate it at build time and not run time.

An unconditional !! would result in GCC doing the test and then
constructing code to turn it into a zero-or-one condition, and with
complicated tests, it can really add a lot of additional complexity,
even if it can properly optimise the simple case.

-- 
FTTC broadband for 0.8mile line: now at 9.7Mbps down 460kbps up... slowly
improving, and getting towards what was expected from it.



More information about the linux-arm-kernel mailing list