Re: using gcc built-ins for bitops?

From: Andrew Morton
Date: Thu Jun 24 2004 - 04:05:57 EST


Arjan van de Ven <arjanv@xxxxxxxxxx> wrote:
>
> gcc 3.4 gained support for several typical bitops as builtin directives.
> Using these over inline asm has a few advantages:
> * gcc can optimize constants into these better
> * gcc can reorder and schedule the code better
> * gcc can allocate registers etc better for the code
>
> The question is if we consider it desirable to go down this road or not. In
> order to help that discussion I've attached a patch below that switches the
> i386 ffz() function to the gcc builtin version, conditional on gcc having
> support for this. Before I go down the road of converting more functions
> and/or architectures.... is this worth doing?

I guess it depends on the resulting code size and quality. Some extra
conversions would be needed for that.

For the implementation it would be nice to have the old-style
implementations in one header and the new-style ones in a separate header.
That would create a bit of an all-or-nothing situation, but that should be
OK?

> +static inline unsigned long ffz (unsigned long word)
> +{
> + return __builtin_ctzl (~word);
> +}

eww, whitepsace innovations.

static inline unsigned long ffz(unsigned long word)
{
return __builtin_ctzl(~word);
}

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/