From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ua1-x934.google.com (mail-ua1-x934.google.com [IPv6:2607:f8b0:4864:20::934]) by sourceware.org (Postfix) with ESMTPS id 0024F385C6DD for ; Mon, 23 Oct 2023 17:48:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0024F385C6DD 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 0024F385C6DD Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::934 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698083304; cv=none; b=L412TbsmG0CKgvB12N/BRIlcrKblmt0OyxCW9pKHrheF8FGEVXxmsMpC1tsl+UqJUjT681ljxaCywPP31iwqzyVy6g7LCyPxY1VWYiVD2+6daFBdusypTXQwG3soiLVre4gz1hwfWh9Toj8XE7E/fyoGAQSAdvChwMeLnl5D8lo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698083304; c=relaxed/simple; bh=FqFASZkKY+4A6D6XIULfDHDedi8u1fdAlXbEHGzrNEk=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=cBcKvphYfU+WxDh9Mtp/A+M24mdszG+1CRKrDetl3X4buJFPT8j2PKD5yhmK/X06dv7aoX+3YuV9Ci0BkxsMibuMPmMAJnpKtQR9zBs1btCGXAKHLuVFRn4GwdJluwqUha35WX960O5dLNyicy49pJLyjtbkxlapvqm6C9k9MqI= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ua1-x934.google.com with SMTP id a1e0cc1a2514c-7b99b89afdbso279949241.0 for ; Mon, 23 Oct 2023 10:48:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cs.washington.edu; s=goo201206; t=1698083302; x=1698688102; 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=h3iWd41ZP+1QWcoy4Etw9uu0aI1bUxdVLu6f/e9Ye64=; b=hJiN2J9ZHj2Cjot2qMxiQJrSrmR6Yf+c7yf1JEVe477tS1mQp77SpnYZqG/fkAwQim oo2Y9rfOcbPn+4yp/wA8e8McWuMuLtqgr786ppExLbMDvh/vqbsvl0NEvKUsu4486EOk /yk5JlXJRZbITVeX3Afzh3zg/uIh3DzEHfxWQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698083302; x=1698688102; 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=h3iWd41ZP+1QWcoy4Etw9uu0aI1bUxdVLu6f/e9Ye64=; b=RspesJrHDGAWAmtq6XL1SndIxKuMApAUHJAAuxCV6aNz5SlPwza1gvQsrkyw9xDJQl xZitqjRtsmp3Vb2+0NxGtgPziVP2RvMli/XdtUQG46C5pDwEvTqMI64W8cg5QDaF1DQu qVVoUqbg9UacWSM+XQc8RYE1zlAwIn+iTf8L0AblFAYMCYVigJvDSPkbbiLKTlXsk07H UzMR41M/7mfLPFmkqbJzJxHtj5YH3vWv2fEE84AI/mWfms2d+OcGW6LhNV71f8ECzdC+ TMDUfosmAaPkk6wogGrPF+Ra4X1mCazfj9KsfeciV8V5gQXVCcsWUyX2v20L8rEXv5Zg KoKg== X-Gm-Message-State: AOJu0Yw71jYAb85bTtlqAjR5rh/G+icUSU26AobPu0R5aTIvBk7/W49r SCq0wxuu6j0evUWnabxip0cYN1VqjQtAdVvpIX6yMw== X-Google-Smtp-Source: AGHT+IGj6p3N3ak8HMDHibKz2uV0N4ns5l7WQy1eZExTtJxmgbTWoE3gjgeGfvCvm0waQKZHZ9kcBNiCo1e3qSJSNis= X-Received: by 2002:a05:6102:2:b0:452:63b7:2f6d with SMTP id j2-20020a056102000200b0045263b72f6dmr9877082vsp.34.1698083301884; Mon, 23 Oct 2023 10:48:21 -0700 (PDT) MIME-Version: 1.0 References: <20231020135748.1846670-1-kmatsui@gcc.gnu.org> <20231020162115.2307797-1-kmatsui@gcc.gnu.org> <20231020162115.2307797-34-kmatsui@gcc.gnu.org> <6fea8e1c-7cdc-fdd9-db6b-b3b2f86f9920@idea> In-Reply-To: <6fea8e1c-7cdc-fdd9-db6b-b3b2f86f9920@idea> From: Ken Matsui Date: Mon, 23 Oct 2023 10:47:46 -0700 Message-ID: Subject: Re: [PATCH v24 33/33] libstdc++: Optimize std::is_invocable compilation 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=-13.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,GIT_PATCH_0,KAM_SHORT,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 23, 2023 at 10:39=E2=80=AFAM Patrick Palka = wrote: > > On Mon, 23 Oct 2023, Ken Matsui wrote: > > > On Mon, Oct 23, 2023 at 10:05=E2=80=AFAM Patrick Palka wrote: > > On Fri, Oct 20, 2023 at 12:22=E2=80=AFPM Ken Matsui wrote: > > > > > > This patch optimizes the compilation performance of std::is_inv= ocable > > > by dispatching to the new __is_invocable built-in trait. > > > > > > libstdc++-v3/ChangeLog: > > > > > > * include/std/type_traits (is_invocable): Use __is_invo= cable > > > built-in trait. > > > > Nice! We should use the trait directly in is_invocable_v too. > > > > > > Thank you! But we want to take account of static_assert=E2=80=99s in is= _invocable, so I think we cannot use the built-in directly? > > Good point, I guess that's a great reason to improvement the diagnostic > that check_trait_type emits: it'd speed up the class template version > because we could get rid of the static_asserts (without regressing > diagnostic quality), and it'd speed up the variable template version > because we could use the built-in directly there. > > Your patch LGTM as is though, that could be a follow-up if anything. > Thank you! I will also work on this after other built-in traits end! > > > > > > > * testsuite/20_util/is_invocable/incomplete_args_neg.cc= : Handle > > > the new error from __is_invocable. > > > * testsuite/20_util/is_invocable/incomplete_neg.cc: Lik= ewise. > > > > > > Signed-off-by: Ken Matsui > > > --- > > > libstdc++-v3/include/std/type_traits | = 6 ++++++ > > > .../testsuite/20_util/is_invocable/incomplete_args_neg.cc | = 1 + > > > .../testsuite/20_util/is_invocable/incomplete_neg.cc | = 1 + > > > 3 files changed, 8 insertions(+) > > > > > > diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v= 3/include/std/type_traits > > > index 75a94cb8d7e..91851b78c7e 100644 > > > --- a/libstdc++-v3/include/std/type_traits > > > +++ b/libstdc++-v3/include/std/type_traits > > > @@ -3167,9 +3167,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION > > > using invoke_result_t =3D typename invoke_result<_Fn, _Arg= s...>::type; > > > > > > /// std::is_invocable > > > +#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_invocable) > > > + template > > > + struct is_invocable > > > + : public __bool_constant<__is_invocable(_Fn, _ArgTypes...)= > > > > +#else > > > template > > > struct is_invocable > > > : __is_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, = void>::type > > > +#endif > > > { > > > static_assert(std::__is_complete_or_unbounded(__type_ide= ntity<_Fn>{}), > > > "_Fn must be a complete class or an unbounded array"); > > > diff --git a/libstdc++-v3/testsuite/20_util/is_invocable/incomp= lete_args_neg.cc b/libstdc++-v3/testsuite/20_util/is_invocable/incomplete_a= rgs_neg.cc > > > index 34d1d9431d1..3f9e5274f3c 100644 > > > --- a/libstdc++-v3/testsuite/20_util/is_invocable/incomplete_ar= gs_neg.cc > > > +++ b/libstdc++-v3/testsuite/20_util/is_invocable/incomplete_ar= gs_neg.cc > > > @@ -18,6 +18,7 @@ > > > // . > > > > > > // { dg-error "must be a complete class" "" { target *-*-* } 0= } > > > +// { dg-prune-output "invalid use of incomplete type" } > > > > > > #include > > > > > > diff --git a/libstdc++-v3/testsuite/20_util/is_invocable/incomp= lete_neg.cc b/libstdc++-v3/testsuite/20_util/is_invocable/incomplete_neg.cc > > > index e1e54d25ee5..92af48c48b6 100644 > > > --- a/libstdc++-v3/testsuite/20_util/is_invocable/incomplete_ne= g.cc > > > +++ b/libstdc++-v3/testsuite/20_util/is_invocable/incomplete_ne= g.cc > > > @@ -18,6 +18,7 @@ > > > // . > > > > > > // { dg-error "must be a complete class" "" { target *-*-* } 0= } > > > +// { dg-prune-output "invalid use of incomplete type" } > > > > > > #include > > > > > > -- > > > 2.42.0 > > > > > > > > >