From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id CDF7C3858410 for ; Mon, 16 Oct 2023 18:04:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CDF7C3858410 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org CDF7C3858410 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697479491; cv=none; b=vo4NhDBBnp//+2ObWmAlNKYmM3lz7Iit/wb1YdKR0yrr4wdZ6bqjjuNjbP7PIDFkwjGqZIRxt9d+9dobnu8blGNUjy7k2pKAs1zd8IZSJFA8h9IGah1gO92lXrxc225aUFxDX092Ye9ttS9OtbzYp86r8Pe/3pQdVH9o8pNbhxk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697479491; c=relaxed/simple; bh=7FlyMqNKk/PMMEiNU+u0gHqlktNSF/GSx9LFxYQ9c/8=; h=DKIM-Signature:From:Date:To:Subject:Message-ID:MIME-Version; b=tOTHe2n0fuZqVX9xcVFHajJneZro6DMnTzMwSwYkl8ExKvn6cDbjKhXwnH4vy89P4b/xu5kvv4ygeviQJJIqDXcHP3Q1G81ovUH4EKPW+qXzx7xP2pTZ3hxhflPEQEXldAWMTENm7RMnCN3ZB/w0hT4ZJ3bpPzNLVRh4DAIsGI8= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697479490; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=r3PGct4IUvC3RRsYrxNne40hn4SyFwd9Zcre6KDr5TU=; b=V5IIZMceWDgYW49j1Npw2cTvCTV5NAnD+IMvfbCrQ2HKSr5C65R7SqmNr2WHFVllKUaN5g 7hhpJppfu+4twIwQt+Jo/qP0ActzllO5E4rI/aBAWHFyX/U7iKYwRa9R3M0jQeXgv3oNfv sq8Rvivsus8M6wE6xN5RsgEtoF46kgw= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-502-1lmz515GMw24mZs2ecoZFA-1; Mon, 16 Oct 2023 14:04:49 -0400 X-MC-Unique: 1lmz515GMw24mZs2ecoZFA-1 Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-66d1e755077so50766316d6.0 for ; Mon, 16 Oct 2023 11:04:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697479488; x=1698084288; h=mime-version:references:message-id:in-reply-to:subject:cc:to:date :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=r3PGct4IUvC3RRsYrxNne40hn4SyFwd9Zcre6KDr5TU=; b=a6GXGAHqM0MXaVf6Ak0B2tSa4Lm2ozZgzrInPdyEctqZu4FoNxzZyPHnieSRTVQBKK vHylff6bhbX8SGXNb7EsnrXRVoRLvdyND67YmSyP0icmF8HJx1XDs9RiByHi+DFI6hsa Ud6WwVOLILVD6s9h9I1odYmbwdhrTNV5LbAA/yrW0Mzjc81SbI2jPqOdwgJ/j1BZqXa/ KJDkDLF1hWdEuLsNBEQ1QERVEPaD5iHUpSNS9n6GtcHcWn1TcHxbqEnmVqdnBUg5H/A7 /0v2WAY93CfASk3ip3KxYt8w72M+3De/dTbgSzkU9ryOAz8wtqvPG3hxOjcn83MuDSfp QgoA== X-Gm-Message-State: AOJu0YxL24yeCCR5myQ38qSkaLPgeu9jnnNxLM7t4vwMWwEw/mmUf75a FWz8LSg/ZgzP94kZK7X9szwZh6nrbLOHqDPCpoznkr7qiN7kiX0exAsUF+g8iuNHSuEqNKBuVFz 0CAaVKDHUIRPHKCU02z0RwBA= X-Received: by 2002:ad4:5dec:0:b0:65d:f81:9b47 with SMTP id jn12-20020ad45dec000000b0065d0f819b47mr169812qvb.45.1697479488533; Mon, 16 Oct 2023 11:04:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEsNSPskkRxG7FRhqBe3EiI7WhudHr5UKpb6y+rcvbniCALk2xY4c1lxu55Bcyys5r8SMYR3w== X-Received: by 2002:ad4:5dec:0:b0:65d:f81:9b47 with SMTP id jn12-20020ad45dec000000b0065d0f819b47mr169790qvb.45.1697479488260; Mon, 16 Oct 2023 11:04:48 -0700 (PDT) Received: from [192.168.1.130] (ool-457670bb.dyn.optonline.net. [69.118.112.187]) by smtp.gmail.com with ESMTPSA id f1-20020a05620a15a100b007756f60bcacsm3158151qkk.79.2023.10.16.11.04.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 11:04:47 -0700 (PDT) From: Patrick Palka X-Google-Original-From: Patrick Palka Date: Mon, 16 Oct 2023 14:04:47 -0400 (EDT) To: Ken Matsui cc: gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org Subject: Re: [PATCH v20 26/40] libstdc++: Optimize is_object trait performance In-Reply-To: <20231016001227.2717180-27-kmatsui@gcc.gnu.org> Message-ID: <752e6e5e-0700-1dd9-f992-241731fb1d03@idea> References: <20231013223957.1634024-1-kmatsui@gcc.gnu.org> <20231016001227.2717180-1-kmatsui@gcc.gnu.org> <20231016001227.2717180-27-kmatsui@gcc.gnu.org> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-14.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=unavailable 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, 15 Oct 2023, Ken Matsui wrote: > This patch optimizes the performance of the is_object trait by dispatching 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/include/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). > +#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 = is_arithmetic<_Tp>::value; > template > inline constexpr bool is_fundamental_v = is_fundamental<_Tp>::value; > + > +#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_function) \ > + && _GLIBCXX_USE_BUILTIN_TRAIT(__is_reference) > +template > + inline constexpr bool is_object_v > + = !(__is_function(_Tp) || __is_reference(_Tp) || is_void<_Tp>::value); > +#else > template > inline constexpr bool is_object_v = is_object<_Tp>::value; > +#endif > + > template > inline constexpr bool is_scalar_v = is_scalar<_Tp>::value; > template > -- > 2.42.0 > >