From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by sourceware.org (Postfix) with ESMTPS id E87873858C50; Sun, 16 Jul 2023 12:41:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E87873858C50 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-3143ccb0f75so3765510f8f.0; Sun, 16 Jul 2023 05:41:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689511274; x=1692103274; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=hAzXdsmlKWYA/1PQTY26tZ+T+8ilcKexBj2NVqmy+LE=; b=b0dp6S/g4YZYoqsFFqAFiqNw0ags/g5e6lWLuMT9723PJon0Icjt5iygHoZbYseSUZ IoYQjYN2PcVSIIgyVvYys5QLguOCjuwBtGJYF3LnmmK5mn5Hcila+7Hp4CSzcAr4BUA9 gtCPyrywntvM2Tqmac54hJ7xc4tAjwptbaOTJ6Ucz3i2QcZuSD7cF49gJ5TJP7G9U645 NGymmsEEMR/xVCdaM30c5lTCm1DMiW+wDYSlYn9F8kpDzhctXerJDGLptf5nt3xKKk+Z +4UUfe4d2fW/YD35I8LmFtzC2Ijrz2u7PGgGrt9nnKFYTU9roF7ZUoBoGOPgVNK1tY+1 iC4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689511274; x=1692103274; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=hAzXdsmlKWYA/1PQTY26tZ+T+8ilcKexBj2NVqmy+LE=; b=YzDI0siGgfE1CeTDTDR0lSSVofAAbBCE0YP/PpNEkDVenAzHfeM4d/+pWO7xLea8W+ ddDAXJ7/Wd9ORwe10t3qMmX5q0lUbO4qD/vpCsu0AC2ufjLwLSUagylVVRa6WLUuGROt V5QQmVc4HeA/JwC5i1G30Fnf/6Y8t+v2v/YozoZpLa1oHvnYWqPhGcB3DC8meQVaXLxp Dto4Unrxqaecn9qH2ssJXbz+4xzXxxsAXUP2JjAxloUhvDJjMvrJAtz0bzaV27RZtRxT 2gZLmH8F/ebEftGOgjMwYaPunEvbJsU1tRnoNDFIRy3Gb+smA+28Z8uZKOuSIdUii6nT X7eA== X-Gm-Message-State: ABy/qLbO5zgWxoMJ0Oca1p4mSgES/XtHOPdRF3ikea4THHw9tyCgj3fv 7HB7p+I+xslKwZvgtFsYRGx8p++3lAE= X-Google-Smtp-Source: APBJJlHCMA23w00f8gUKNgdOQim+sZwciZh5aOzXaKlPP4MSWFPxsgwnybkcOsc0mjCXfk08FcWnUg== X-Received: by 2002:a5d:4e87:0:b0:316:fc86:28ae with SMTP id e7-20020a5d4e87000000b00316fc8628aemr1757489wru.15.1689511274229; Sun, 16 Jul 2023 05:41:14 -0700 (PDT) Received: from [192.168.42.216] (pop.92-184-112-146.mobile.abo.orange.fr. [92.184.112.146]) by smtp.gmail.com with ESMTPSA id g15-20020a5d554f000000b0031411e46af3sm16222500wrw.97.2023.07.16.05.41.13 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 16 Jul 2023 05:41:13 -0700 (PDT) Message-ID: <3aa7cf30-27f1-7e69-7334-fc9918928f90@gmail.com> Date: Sun, 16 Jul 2023 14:41:12 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [PATCH v2 3/3] libstdc++: Optimize is_fundamental performance by __is_arithmetic built-in Content-Language: en-US To: Ken Matsui , gcc-patches@gcc.gnu.org Cc: libstdc++@gcc.gnu.org References: <20230709125715.26884-1-kmatsui@gcc.gnu.org> <20230715045519.50684-1-kmatsui@gcc.gnu.org> <20230715045519.50684-3-kmatsui@gcc.gnu.org> From: =?UTF-8?Q?Fran=c3=a7ois_Dumont?= In-Reply-To: <20230715045519.50684-3-kmatsui@gcc.gnu.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 15/07/2023 06:55, Ken Matsui via Libstdc++ wrote: > This patch optimizes the performance of the is_fundamental trait by > dispatching to the new __is_arithmetic built-in trait. > > libstdc++-v3/ChangeLog: > > * include/std/type_traits (is_fundamental_v): Use __is_arithmetic > built-in trait. > (is_fundamental): Likewise. Optimize the original implementation. > > Signed-off-by: Ken Matsui > --- > libstdc++-v3/include/std/type_traits | 21 +++++++++++++++++---- > 1 file changed, 17 insertions(+), 4 deletions(-) > > diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits > index 7ebbe04c77b..cf24de2fcac 100644 > --- a/libstdc++-v3/include/std/type_traits > +++ b/libstdc++-v3/include/std/type_traits > @@ -668,11 +668,21 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION > #endif > > /// is_fundamental > +#if __has_builtin(__is_arithmetic) > + template > + struct is_fundamental > + : public __bool_constant<__is_arithmetic(_Tp) > + || is_void<_Tp>::value > + || is_null_pointer<_Tp>::value> > + { }; What about doing this ? template struct is_fundamental : public __bool_constant<__is_arithmetic(_Tp) || __or_, is_null_pointer<_Tp>>::value> { }; Based on your benches it seems that builtin __is_arithmetic is much better that std::is_arithmetic. But __or_ could still avoid instantiation of is_null_pointer.