From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-vk1-xa2c.google.com (mail-vk1-xa2c.google.com [IPv6:2607:f8b0:4864:20::a2c]) by sourceware.org (Postfix) with ESMTPS id 4EE073856DE7 for ; Mon, 16 Oct 2023 20:27:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4EE073856DE7 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 ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 4EE073856DE7 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::a2c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697488056; cv=none; b=FeaJ0UWWWqJ/ZPCMLPjTlp8zBMF/KOvNk+jHGKgC3IsmiwD4i4W+iAwwtB5HwtUfrOJoVXUsP0ztx7Tww4oVWQBkix5XFUKeIjFM8SfO9xu2VPkJQkC2Iw27B9Vry/an8YwyJpuz70MYZhOt2r6PZXPeRaRzzCnFUD17l7OdmC8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697488056; c=relaxed/simple; bh=IVpv+s5/fdIfrIS6D3G0w5nl1iJiUVjJZjSrR9UiPz8=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=cK6gjCey0mvup5xBFtV/omK0IhvN8PabpPZ9qVB1X5LKDl0lAprpdOXnnM6osH/R5hqNxoIr5Z+q5dF6SaX0eF0S8qXhrr0UrDkQ0lq9MwwK5uP528RrfBnpAYOjerP//hxRb/BoM7bak7Xav2XXSKZVAovtfVAIhlhCo4e0yOk= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-vk1-xa2c.google.com with SMTP id 71dfb90a1353d-49b289adca9so1963749e0c.3 for ; Mon, 16 Oct 2023 13:27:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cs.washington.edu; s=goo201206; t=1697488054; x=1698092854; darn=gcc.gnu.org; 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=Xa5gmGzazHXboypIjpAKS3MaJc6TOlztJi7pixQXY7w=; b=fCVuH0Yimd2GE4rkJDjNhVorrTXORxI/W3uxEbXUfmiQdAPF1fj8RJA4qJ1WNLflPZ Od9d9eLJMhEmxsI6Qv0l3pqC1W8pt3EOoYJZL7Nd6O4guggb7H0hvni7UOOlo0F2/DUG yvF4WJ0r0hHK3lXum39e1iHNaZs9i3jErrTMs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697488054; x=1698092854; 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=Xa5gmGzazHXboypIjpAKS3MaJc6TOlztJi7pixQXY7w=; b=KWFmOifSn82t0cxQt0vcOrBLlAg1di8FLrUK7M4Y4ubG1ilXAzmVEaCh/GJtu8scCz 3LjJB9GsfZniHxSbmBA6qYzM2qywT0DaGlFMW3wNJGnYbPjmm7ffJQzAmrnExro0Pxi/ txe7z0CMvynXVo6UXp2e53zVoL+J0E+ld2i7a6g8opEAaXpq/a5vDDSFaV4AFYRfHxUw BsEGjY+3vsp1l9hj0Ls7uz0YeG420VQZOWjX0SgE4Ner3oZ/hW/Wxk7X/W8CtrY+3qrl xmgwC+EKiCIEV2TRbq53jGYNSKM0VUpT8hhbcPgJB80WOihU6YCxvAP+jQbhsk/hPSxn uqoQ== X-Gm-Message-State: AOJu0YwSEFIpK9AStYfmVgW522zCNwg0t2NcNus7R1AApgjmpFluhHqn A39tmxE0IbaMQux/xaR6e8lhDsZPTHieS4fKOwDdGQ== X-Google-Smtp-Source: AGHT+IFLuO4CL4g9d64KaQcpErBwxR2dM6NWM5z8K8NgzlxlDbg4KdZlFA8qBRcspt6fpDYpiTckw2Zugommd8omnnc= X-Received: by 2002:a05:6122:736:b0:4a0:6fd4:4334 with SMTP id 54-20020a056122073600b004a06fd44334mr526231vki.12.1697488054586; Mon, 16 Oct 2023 13:27:34 -0700 (PDT) MIME-Version: 1.0 References: <20231013223957.1634024-1-kmatsui@gcc.gnu.org> <20231016001227.2717180-1-kmatsui@gcc.gnu.org> <20231016001227.2717180-27-kmatsui@gcc.gnu.org> <752e6e5e-0700-1dd9-f992-241731fb1d03@idea> In-Reply-To: <752e6e5e-0700-1dd9-f992-241731fb1d03@idea> From: Ken Matsui Date: Mon, 16 Oct 2023 13:26:58 -0700 Message-ID: Subject: Re: [PATCH v20 26/40] libstdc++: Optimize is_object trait performance To: Patrick Palka 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=-11.0 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 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 Mon, Oct 16, 2023 at 11:04=E2=80=AFAM Patrick Palka = wrote: > > On Sun, 15 Oct 2023, Ken Matsui wrote: > > > This patch optimizes the performance of the is_object trait by dispatch= ing to > > the new __is_function and __is_reference built-in traits. > > > > libstdc++-v3/ChangeLog: > > * include/std/type_traits (is_object): Use __is_function and > > __is_reference built-in traits. > > (is_object_v): Likewise. > > > > Signed-off-by: Ken Matsui > > --- > > libstdc++-v3/include/std/type_traits | 18 ++++++++++++++++++ > > 1 file changed, 18 insertions(+) > > > > diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/includ= e/std/type_traits > > index bd57488824b..674d398c075 100644 > > --- a/libstdc++-v3/include/std/type_traits > > +++ b/libstdc++-v3/include/std/type_traits > > @@ -725,11 +725,20 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION > > { }; > > > > /// is_object > > +#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_function) \ > > + && _GLIBCXX_USE_BUILTIN_TRAIT(__is_reference) > > + template > > + struct is_object > > + : public __bool_constant > + || is_void<_Tp>::value)> > > + { }; > > Since is_object is one of the more commonly used traits, we should > probably just define a built-in for it. (Either way we'd have to > repeat the logic twice, either once in the frontend and once in > the library, or twice in the library (is_object and is_object_v), > so might as well do the more efficient approach). > Sure, I'll implement it :) Thank you for your review! > > +#else > > template > > struct is_object > > : public __not_<__or_, is_reference<_Tp>, > > is_void<_Tp>>>::type > > { }; > > +#endif > > > > template > > struct is_member_pointer; > > @@ -3305,8 +3314,17 @@ template > > inline constexpr bool is_arithmetic_v =3D is_arithmetic<_Tp>::value; > > template > > inline constexpr bool is_fundamental_v =3D is_fundamental<_Tp>::valu= e; > > + > > +#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_function) \ > > + && _GLIBCXX_USE_BUILTIN_TRAIT(__is_reference) > > +template > > + inline constexpr bool is_object_v > > + =3D !(__is_function(_Tp) || __is_reference(_Tp) || is_void<_Tp>::v= alue); > > +#else > > template > > inline constexpr bool is_object_v =3D is_object<_Tp>::value; > > +#endif > > + > > template > > inline constexpr bool is_scalar_v =3D is_scalar<_Tp>::value; > > template > > -- > > 2.42.0 > > > > >