[PATCH 0/7] minmax: reduce compilation time

From: David Laight
Date: Wed Jul 24 2024 - 10:27:23 EST


The changes to minmax.h that changed the type check to a signedness
check significantly increased the length of the expansion.
In some cases it has also significantly increased compile type.
This is particularly noticeable for nested expansions.

These changes reduce the expansions somewhat.
The biggest change is the last patch that directly implements
min3() and max3() rather than using a nested expansion.

Further significant improvements can be made by removing the
requirement that min(1,2) be 'constant enough' for an array size.
Instead supporting MIN() and MAX() for constants only with a result
that is valid for a static initialiser.
However that needs an initial change to the few files that have
local versions of MIN() or MAX().


David Laight (7):
minmax: Put all the clamp() definitions together
minmax: Use _Static_assert() instead of static_assert()
compiler.h: Add __if_constexpr(expr, if_const, if_not_const)
minmax: Simplify signedness check
minmax: Factor out the zero-extension logic from umin/umax.
minmax: Optimise _Static_assert() check in clamp().
minmax: minmax: Add __types_ok3() and optimise defines with 3
arguments

include/linux/compiler.h | 65 +++++----------
include/linux/minmax.h | 176 ++++++++++++++++++++-------------------
2 files changed, 113 insertions(+), 128 deletions(-)

--
2.17.1

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)