Re: [PATCH 4/7] minmax: Simplify signedness check

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jul 24, 2024, at 16:30, David Laight wrote:
> It is enough to check that both 'x' and 'y' are valid for either
> a signed compare or an unsigned compare.
> For unsigned they must be an unsigned type or a positive constant.
> For signed they must be signed after unsigned char/short are promoted.
>
> Order the expressions to avoid warnings about comparisons that are
> always true.
>
> Signed-off-by: David Laight <david.laight@xxxxxxxxxx>

This patch gives me a 10x speedup on compiling arch/x86/xen/setup.c,
taking it from 15 seconds to 1.5 seconds for a defconfig+CONFIG_XEN
build.

>+/* Allow unsigned compares against non-negative signed constants. */
>+#define __is_ok_unsigned(x) \
>+	((is_unsigned_type(typeof(x)) ? 0 : __if_constexpr(x, (x) + 0, -1)) >= 0)

I don't understand why this return '0' for unsigned types,
shouldn't this be

((is_unsigned_type(typeof(x)) ? 1 : __if_constexpr(x, (x) + 0, -1)) >= 0)

?

    Arnd




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux