From patchwork Sun Jul 28 14:15:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Laight X-Patchwork-Id: 13744001 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 20EAEC3DA49 for ; Sun, 28 Jul 2024 14:16:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2D7F86B007B; Sun, 28 Jul 2024 10:16:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 261B76B0083; Sun, 28 Jul 2024 10:16:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 101AB6B0085; Sun, 28 Jul 2024 10:16:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id E1F0A6B007B for ; Sun, 28 Jul 2024 10:16:48 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 8D5421202C6 for ; Sun, 28 Jul 2024 14:16:48 +0000 (UTC) X-FDA: 82389362496.06.5CA401E Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.85.151]) by imf07.hostedemail.com (Postfix) with ESMTP id C975540018 for ; Sun, 28 Jul 2024 14:16:44 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=none; spf=pass (imf07.hostedemail.com: domain of david.laight@aculab.com designates 185.58.85.151 as permitted sender) smtp.mailfrom=david.laight@aculab.com; dmarc=pass (policy=none) header.from=aculab.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1722176165; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references; bh=sVNwtKYl7st2slficN3E75kt2e+zFYVJnYH6tiZWOU8=; b=oAyaGE7KqohOMnz4kGlXnIVNvqN80ajN/lcLna66oSyJlsHqd3pmvvzK10fGZHW2HpaTr0 NrpPtYvfaUSjc+5LXoA346Xougehhs4/gXFTtSWq83PktvdyVQr6xJ2qDnWxkq7YZYID4T zagzi/0Fs1Fx9jc2cOchx9TuAWpEEGs= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=none; spf=pass (imf07.hostedemail.com: domain of david.laight@aculab.com designates 185.58.85.151 as permitted sender) smtp.mailfrom=david.laight@aculab.com; dmarc=pass (policy=none) header.from=aculab.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722176165; a=rsa-sha256; cv=none; b=QXvcZsjdTe4SAJWCMP9SZQzRvcfbyTF10uKgeAOMMsxIp4iXgx6NfMWI/pYk2O+HaXWo9T SDmgtqO2omlXEEDECNnR4fqRYWijZxWDLk9j4V+jNwJSoByLxBC/BMlMQMQPDel8SjDJYc ydrwFVpu9U9gOnsaMggOicpOII1Hoqc= Received: from AcuMS.aculab.com (156.67.243.121 [156.67.243.121]) by relay.mimecast.com with ESMTP with both STARTTLS and AUTH (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id uk-mta-214-02zQ_LJvPdOjNY95HXxCVw-1; Sun, 28 Jul 2024 15:16:35 +0100 X-MC-Unique: 02zQ_LJvPdOjNY95HXxCVw-1 Received: from AcuMS.Aculab.com (10.202.163.6) by AcuMS.aculab.com (10.202.163.6) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Sun, 28 Jul 2024 15:15:51 +0100 Received: from AcuMS.Aculab.com ([::1]) by AcuMS.aculab.com ([::1]) with mapi id 15.00.1497.048; Sun, 28 Jul 2024 15:15:51 +0100 From: David Laight To: "linux-kernel@vger.kernel.org" CC: 'Linus Torvalds' , Jens Axboe , "Matthew Wilcox (Oracle)" , "Christoph Hellwig" , Andrew Morton , "Andy Shevchenko" , Dan Carpenter , Arnd Bergmann , "Jason@zx2c4.com" , "pedro.falcato@gmail.com" , Mateusz Guzik , "linux-mm@kvack.org" , 'Lorenzo Stoakes' Subject: [PATCH v2 0/8] minmax: reduce compilation time Thread-Topic: [PATCH v2 0/8] minmax: reduce compilation time Thread-Index: Adrg+KhCWB2cpLIWSWqM61xRSOy7tg== Date: Sun, 28 Jul 2024 14:15:51 +0000 Message-ID: <402c3c617c29465c898b1af55e3c6095@AcuMS.aculab.com> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US X-Stat-Signature: 9868coqx59hyw1uhizfgasshtxhri1ec X-Rspam-User: X-Rspamd-Queue-Id: C975540018 X-Rspamd-Server: rspam02 X-HE-Tag: 1722176204-21156 X-HE-Meta: U2FsdGVkX19teZRrZS+yZbRwpvu4LUPC99xgczBjKImAuOlaLvOnqqxmr9MCwxc7Sac991jpirEpfiFrjQ6yuZkWTrz+/dBLAjcsPEa/gTePmU3xHs0LO/CKRON77ZdRDNCp9RZx31AiTojnrrtphtwP0iBwTnTgPTRvPZhFLT6j47y3nGtEacjLcEiP9ToFjm8MG5cKzToXk2aTyueTNwm7acUjuP0BbHP1iud3AJxvCJeNBBgeHfL22UfJzbcA0NBNBWq4ulVynVky/oXewnn30ojJtVGZOuLfDapymF++8E3lHPEXqBAtFhLapVwZKORM82zkTOk0hASUcHCAlc8PJ1vjT+NG5eNMmgp6pRz4lvNge1nkUlWhOvdk+2sI7u+34JjvKYBLhoWZWrO4JcZDgrXeNNVHnd4R7NUi6EXKDJJN4pPLftSfdBcScH6V+k9CxjnknT9sqv/TbgV8Xo8jOq+MKtRdEtn7NXEwh9bsvziHQN1VKv8sKJjlTw2YmS7pP7LJCIYYrqr6X2SkbETYfsy3S4onMTPRH4FQKnmF/n8paBGjZUesJhh+bSkYWxYk4GwJs23ToxC28iqc77V0yoZuotWVdL+8zjxN6RXkPVmPjSfuJb7pb74dZGs/eUqeIqEUhyGiSzccGRUxospTF7EZcANCubyHyoKy0SQQTyvvDezdYNc5burS6dhtpC/h/tMWoxtHeBNifdE1ZZ0tgfvg34+Wdnn1/6twUJcMnJSpiLmysXDqphvzVxcJ7243zsxjQjzJKAAbVeIkprdIZWnUF8U/r765dJqspR4RTr+JUOQa9pN+nVj1OBczCJDxmOR8EGnm/I1bKsTzf9eyzsMPrFPZ8zjkyvpQNfn4bNtZtLytaC2O735a1txpCwwMmjCPABjSsFZOPQF2O6n9RMx3L55enKFOobaMsiCrbvoukvcOncR0ezbfGXJQGw+QpbqGq9IYLAx/xBQ z5xlhR7T eG3dJ8+IDrpaPyogSyKeZe1ah4bCjiWjFbw54qawrNczws7FctHS5WIYRVBWrxphHhJluNbq0iMTAwW5RRPDzgcDrx1YHo8ZLPIz4X9hoAhr0LGGZSL2lImD/K64rDKhSJVilN5+CAqXMY3ltkbN9/ppk34Tg/q00VF/ClB4Fx1UdEjgfNT/UFYk6hU5GjiGkttHek14B/J9LD6wEdbsiA6gXsd8meBi/eLQePpm84ax9wovkn3Xklq1+hn1SEo2GaIzdZ9zVTF5ZXDmh5cLf4oZuxJUCDu0B8oF1hABQk65nJN4daDyEPXYBWAMG3L593L+O49dcFIMOfF5DmBPola5w1Q== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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 supporing 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(). Main changes for v2: - Keep existing definition of __is_constexpr(). - Fix warning in signedness test for pointer types. - Use __auto_type (From Arnd). David Laight (8): 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: Use __auto_type minmax: minmax: Add __types_ok3() and optimise defines with 3 arguments include/linux/compiler.h | 17 ++++ include/linux/minmax.h | 188 +++++++++++++++++++++------------------ 2 files changed, 117 insertions(+), 88 deletions(-)