From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by sourceware.org (Postfix) with ESMTPS id EEE083858C50; Sun, 16 Jul 2023 12:32:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EEE083858C50 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-wm1-x336.google.com with SMTP id 5b1f17b1804b1-3fbc6ab5ff5so31483605e9.1; Sun, 16 Jul 2023 05:32:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689510742; x=1692102742; 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=3113aCX/AsdD9WKZ45kx9On+cL3FOrH6E2AdShH47Fk=; b=TaSJrLdDkpjcnzUReXDBHKkrnOoI8NdkB8HjxsxD70Gjaw9Wg+Ruqzl5REHDfOyH0u gCcqy5XYgY6idzVjk8Go50j3uETwIK1fMXf+5tyypBjnU9CjkrzQPcIofgRV9PPfnkxb BIaBp9zMEjnBAXDayHBuati8Y+ocuSgvyKbux4OYuwTgcWeO3ZLFSVdC4kRYGz9bblY5 0rGNg8KEAYWW1nfqlnyBpp9VvA6YLiyNLATZO3wuaG1DprmHFsmSGcSebwkSK9niGhoB //iJAgYnmgcg8sJRYDeyDVL1L/rQWaU20KKrilXDWYmRhdVTj3YYXMCrp11SfvNQqdQc 6bRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689510742; x=1692102742; 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=3113aCX/AsdD9WKZ45kx9On+cL3FOrH6E2AdShH47Fk=; b=WY1IIrV/o+4plo5lFt0jyU2fm+CBh3irr8SJMoOUj7R/yoZuolS+h/RIBu+PlSSuLy m0sAuEu1oPZUqUpEGuQoAnz7Tw39hChh2gkoGnAlg1SRwBgisB0GQM5jHMfhgHroiwSm caEdT13AdhDT1v0Ye7tYIhka7v/qleyZOKpSAQ1bAUCCkNJhJuSJIc15L7/dV8yFaf6w c+6Z0hO2xBUZk2e+HevaK9vFDalKq8ZmuoI5dw1Rkvj1h10JAGYZp0/h6zvvwP1FySDa +iGpCeJxhyJNDEDDSCaZVSAzpUFD3pMtT8JzsIbb+jFoYhlmaOlcCaTncVE2dHnuOEwp Mytw== X-Gm-Message-State: ABy/qLZJmtVwm61eIrznXTh1JxsP804NCxTxVuW2cpG4HZINF+p34s+6 IE8ewlJlkAYYyaW+5NDSH3GAJdH1fhw= X-Google-Smtp-Source: APBJJlFKsrRtB4JHYy/p6mdeGrJrEezoM8AfyFoVOQUUjxVkJ9eANzIvCujp4/m6ovLsa5j41ZmLLw== X-Received: by 2002:a7b:cd14:0:b0:3fc:472:d1e9 with SMTP id f20-20020a7bcd14000000b003fc0472d1e9mr7606207wmj.23.1689510741719; Sun, 16 Jul 2023 05:32:21 -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 n14-20020a5d4c4e000000b00316fc844be7sm1834295wrt.36.2023.07.16.05.32.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 16 Jul 2023 05:32:21 -0700 (PDT) Message-ID: <69c70c3c-e197-10b9-1a5b-feef2fe79d61@gmail.com> Date: Sun, 16 Jul 2023 14:32:20 +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 2/3] libstdc++: Optimize is_arithmetic 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-2-kmatsui@gcc.gnu.org> From: =?UTF-8?Q?Fran=c3=a7ois_Dumont?= In-Reply-To: <20230715045519.50684-2-kmatsui@gcc.gnu.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 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_arithmetic trait by > dispatching to the new __is_arithmetic built-in trait. > > libstdc++-v3/ChangeLog: > > * include/std/type_traits (is_arithmetic): Use __is_arithmetic > built-in trait. > (is_arithmetic_v): Likewise. > > Signed-off-by: Ken Matsui > --- > libstdc++-v3/include/std/type_traits | 14 ++++++++++++++ > 1 file changed, 14 insertions(+) > > diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits > index 0e7a9c9c7f3..7ebbe04c77b 100644 > --- a/libstdc++-v3/include/std/type_traits > +++ b/libstdc++-v3/include/std/type_traits > @@ -655,10 +655,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION > { }; > > /// is_arithmetic > +#if __has_builtin(__is_arithmetic) > + template > + struct is_arithmetic > + : public __bool_constant<__is_arithmetic(_Tp)> > + { }; > +#else > template > struct is_arithmetic > : public __or_, is_floating_point<_Tp>>::type > { }; > +#endif > > /// is_fundamental > template > @@ -3198,8 +3205,15 @@ template > inline constexpr bool is_reference_v<_Tp&> = true; > template > inline constexpr bool is_reference_v<_Tp&&> = true; > + > +#if __has_builtin(__is_arithmetic) > +template > + inline constexpr bool is_arithmetic_v = __is_arithmetic(_Tp); > +#else > template > inline constexpr bool is_arithmetic_v = is_arithmetic<_Tp>::value; > +#endif > + > template > inline constexpr bool is_fundamental_v = is_fundamental<_Tp>::value; > template Same remark as the one I did for __is_pointer in cpp_type_traits.h. You could implement it as:   template     struct __is_arithmetic_t     : public __truth_type<__is_arithmetic(_Tp)>     { }; François