From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ua1-x936.google.com (mail-ua1-x936.google.com [IPv6:2607:f8b0:4864:20::936]) by sourceware.org (Postfix) with ESMTPS id 5B4A93858D33 for ; Mon, 17 Jul 2023 04:48:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5B4A93858D33 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=cs.washington.edu Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=cs.washington.edu Received: by mail-ua1-x936.google.com with SMTP id a1e0cc1a2514c-78f32e233a0so1330737241.0 for ; Sun, 16 Jul 2023 21:48:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cs.washington.edu; s=goo201206; t=1689569311; x=1692161311; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=hDTviEG39F5uO71M4+bx2EldOaGFImYLGOAVJLVW8Mk=; b=FUznh4AvOLg/NJlPLldRi+X14doaNsA2RE5Tu1K5EGSJPWJBKEcu2ZEeIz28JoHwII KHJ0BSVfW2h4eS/3Hgp/YugnvAEJocWxW7bgmzY18B8BZoEMrJQ8uTCqUQuVzdbYJp9B hAU3ILwi74TwG3bcwHVMelQz2nlOwcE2J6G9U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689569311; x=1692161311; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hDTviEG39F5uO71M4+bx2EldOaGFImYLGOAVJLVW8Mk=; b=BFz1fETV38qbnTQ/0HYddxmnWQmtz8mk6XMoUj4UkGdXzg7VwtqN4v4y+HRG0tdz12 weiDR9KFY+fcIyTP0vk8klnOvUxWo5gX3X8eMWOYJg15vN9cZuGdf5ajRJS5Nf4R53Pp MuTLxIzUuoBVIJCNpC9IbzGqwPmPjvg5l7AcV0wOfAzkDlxuK30gqJg6Kv+wITJEkUpq /Ce6wprJpfK0/CMVfiIrzhFkWMnaDVmhAablhk1z7mjmzy0D9C7S0vpzaEin9w7Y3FMX Jhdz5vpQp0A/9GuQ/yb1Xatn/Xh135HkEjUYCqXXTzgM/6176qkkAnxlCR0rkoV5nWZQ E4Ag== X-Gm-Message-State: ABy/qLbbCVgYl6EjYZGxryAq8IEt+z9zjWFNBv5r1u1ckUtYHm9wjjht PVuPt6hf70LW/wcVJSJPpgrKh2jTNwiHLXzxrv2PANnRis/6XPc7 X-Google-Smtp-Source: APBJJlE7eCTDnUM8Wd4u5leuxHf3OMqp5Bl7vUJG/kNLu0b0RnPrvFcH3fA6xinRmDWpfq0c/K2c4tiz4T4lUCAyeeM= X-Received: by 2002:a67:f5ce:0:b0:443:7bbc:e397 with SMTP id t14-20020a67f5ce000000b004437bbce397mr5819945vso.26.1689569310955; Sun, 16 Jul 2023 21:48:30 -0700 (PDT) MIME-Version: 1.0 References: <20230709125715.26884-1-kmatsui@gcc.gnu.org> <20230715045519.50684-1-kmatsui@gcc.gnu.org> <20230715045519.50684-2-kmatsui@gcc.gnu.org> <69c70c3c-e197-10b9-1a5b-feef2fe79d61@gmail.com> In-Reply-To: <69c70c3c-e197-10b9-1a5b-feef2fe79d61@gmail.com> From: Ken Matsui Date: Sun, 16 Jul 2023 21:48:15 -0700 Message-ID: Subject: Re: [PATCH v2 2/3] libstdc++: Optimize is_arithmetic performance by __is_arithmetic built-in To: =?UTF-8?Q?Fran=C3=A7ois_Dumont?= Cc: Ken Matsui , gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-10.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,GIT_PATCH_0,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 Sun, Jul 16, 2023 at 5:32=E2=80=AFAM Fran=C3=A7ois Dumont wrote: > > > 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/includ= e/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&> =3D true; > > template > > inline constexpr bool is_reference_v<_Tp&&> =3D true; > > + > > +#if __has_builtin(__is_arithmetic) > > +template > > + inline constexpr bool is_arithmetic_v =3D __is_arithmetic(_Tp); > > +#else > > template > > inline constexpr bool is_arithmetic_v =3D is_arithmetic<_Tp>::value= ; > > +#endif > > + > > template > > inline constexpr bool is_fundamental_v =3D is_fundamental<_Tp>::val= ue; > > 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=C3=A7ois > Thank you for your review! This is from the type_traits header, so the name should be as-is.