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 2A48B3858C60 for ; Sun, 22 Oct 2023 12:07:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2A48B3858C60 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 2A48B3858C60 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=1697976436; cv=none; b=soSF+aMGHDklFrXjOXHWMmADK4SxmgzZ3jFlc461ZUj7NwRhdbE1qZSKhJ7KsWEiOPxR9mAsxJlBRBGiCr+SiVOLCQwS0Hf0RSim1Z2roPADGyn+tplkvVr8I0Owr1QZG9LohvOVyinrSggGj2I+D9nTdNM1Nl4WIxInGOSTNF8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697976436; c=relaxed/simple; bh=bvwCy1QOlZ/yc9RIDofrvd1AUNEc+3l2T93uqUUXVuU=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=JQ3qUuUk7ldGU8Y5nvKpjGkIS5Vd9G51LRV/uwojtbwaJgo6WGND/rdktWUN4aiUttT9cvU7ZS7nkjp1Xu8WiqKCIiBRdaErrh7ncWZwJuLaVL/W4l+42OtFP35XeuKEp4DSDucpc0/AM0xWoMQYF1lzUU0RM0lJRJBqXVJWTbU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-vk1-xa2c.google.com with SMTP id 71dfb90a1353d-49d45964fcaso2319075e0c.1 for ; Sun, 22 Oct 2023 05:07:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cs.washington.edu; s=goo201206; t=1697976433; x=1698581233; 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=3eLHnUKUfRKfWO5SJHx+1ZwQwR2V1NHgYe5qt2g8VqY=; b=bWG0nGeGInxE/tIDEqUUtsDej58xWjVcx5oniyExZPNYMF1gkSIOnSfwDrfXmEUZmd n04vStJqIhnKCP4Xgxeq2yJXr9o9R6QjJeAWoSPN3j9PPXFjAFDfVm1l8pD9XcJ5CtF+ 8u0EVQInCTpWyLo4hETLNonM5muIq8ls9ZeRM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697976433; x=1698581233; 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=3eLHnUKUfRKfWO5SJHx+1ZwQwR2V1NHgYe5qt2g8VqY=; b=nJ3r1Bbs600A7odJRVY5Egkxi03cbEr4ckqZzB888V8t0PIFAyMgEz9u8cOkTCyjjv 6ANRDIFHbTDwz0jVrIzidh71pQbGOp3qRsR2mTkh7+z02Q2p0R6//sAWXfCv/54ynBEM xpXZYcW1toVjlqJmTMGMREXCyJuo11N3TGufJ8pfBsJOfs6EADN0CYMlviD6lU/dpjw0 nz+EsueNzUxpNJp0O5FkE4t5eqDOBYDFV15mTpWyZd0hm0iQqgOyCNuguBJyT7b4Fi3x KkMhrtZyqGQCC1QAwUqlCc7QyAfhNLtj9NPG0Rd7p/nhD9gN8UnGdcrxUxjT1GEebtOP F4bg== X-Gm-Message-State: AOJu0YxZe7xd2YT1cAXkEmfT0uLy1EVKh+3y52hm3r8LteMP6Zwu4Ard oZg5Zyt0w67bIX50ZZ2lUSnxWuO7k7Jn2HruoRCNmw== X-Google-Smtp-Source: AGHT+IHcswTLGm4iNLC7zfgR+DmJVqE177DDIVh7qJQ7SDoAxqKtLx+BcFGx7HWH0mS7X9iefOtKmPpr087HdJjqcUQ= X-Received: by 2002:a05:6122:706:b0:49a:9f99:bb03 with SMTP id 6-20020a056122070600b0049a9f99bb03mr3342856vki.1.1697976433390; Sun, 22 Oct 2023 05:07:13 -0700 (PDT) MIME-Version: 1.0 References: <20231017113822.677344-1-kmatsui@gcc.gnu.org> <20231020135748.1846670-1-kmatsui@gcc.gnu.org> <20231020135748.1846670-32-kmatsui@gcc.gnu.org> In-Reply-To: <20231020135748.1846670-32-kmatsui@gcc.gnu.org> From: Ken Matsui Date: Sun, 22 Oct 2023 05:06:37 -0700 Message-ID: Subject: Re: [PATCH v23 31/33] libstdc++: Optimize std::is_pointer compilation performance To: Patrick Palka Cc: gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org, Ken Matsui , Jonathan Wakely Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-11.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 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: Hi Patrick, There is an issue with the code in libstdc++-v3/include/bits/cpp_type_traits.h. Specifically, Clang 16 does not accept the code, while Clang 17 does. Given that we aim to support the last two versions of Clang, we need to ensure that Clang 16 accepts this code. Can you please advise on the best course of action regarding this matter? https://godbolt.org/z/PbxhYcb7q Sincerely, Ken Matsui On Fri, Oct 20, 2023 at 7:12=E2=80=AFAM Ken Matsui wr= ote: > > This patch optimizes the compilation performance of std::is_pointer > by dispatching to the new __is_pointer built-in trait. > > libstdc++-v3/ChangeLog: > > * include/bits/cpp_type_traits.h (__is_pointer): Use __is_pointer > built-in trait. > * include/std/type_traits (is_pointer): Likewise. Optimize its > implementation. > (is_pointer_v): Likewise. > > Co-authored-by: Jonathan Wakely > Signed-off-by: Ken Matsui > --- > libstdc++-v3/include/bits/cpp_type_traits.h | 8 ++++ > libstdc++-v3/include/std/type_traits | 44 +++++++++++++++++---- > 2 files changed, 44 insertions(+), 8 deletions(-) > > diff --git a/libstdc++-v3/include/bits/cpp_type_traits.h b/libstdc++-v3/i= nclude/bits/cpp_type_traits.h > index 4312f32a4e0..246f2cc0b17 100644 > --- a/libstdc++-v3/include/bits/cpp_type_traits.h > +++ b/libstdc++-v3/include/bits/cpp_type_traits.h > @@ -363,6 +363,13 @@ __INT_N(__GLIBCXX_TYPE_INT_N_3) > // > // Pointer types > // > +#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_pointer) > + template > + struct __is_pointer : __truth_type<__is_pointer(_Tp)> > + { > + enum { __value =3D __is_pointer(_Tp) }; > + }; > +#else > template > struct __is_pointer > { > @@ -376,6 +383,7 @@ __INT_N(__GLIBCXX_TYPE_INT_N_3) > enum { __value =3D 1 }; > typedef __true_type __type; > }; > +#endif > > // > // An arithmetic type is an integer type or a floating point type > diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/= std/type_traits > index 0641ecfdf2b..75a94cb8d7e 100644 > --- a/libstdc++-v3/include/std/type_traits > +++ b/libstdc++-v3/include/std/type_traits > @@ -542,19 +542,33 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION > : public true_type { }; > #endif > > - template > - struct __is_pointer_helper > + /// is_pointer > +#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_pointer) > + template > + struct is_pointer > + : public __bool_constant<__is_pointer(_Tp)> > + { }; > +#else > + template > + struct is_pointer > : public false_type { }; > > template > - struct __is_pointer_helper<_Tp*> > + struct is_pointer<_Tp*> > : public true_type { }; > > - /// is_pointer > template > - struct is_pointer > - : public __is_pointer_helper<__remove_cv_t<_Tp>>::type > - { }; > + struct is_pointer<_Tp* const> > + : public true_type { }; > + > + template > + struct is_pointer<_Tp* volatile> > + : public true_type { }; > + > + template > + struct is_pointer<_Tp* const volatile> > + : public true_type { }; > +#endif > > /// is_lvalue_reference > template > @@ -3252,8 +3266,22 @@ template > inline constexpr bool is_array_v<_Tp[_Num]> =3D true; > #endif > > +#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_pointer) > +template > + inline constexpr bool is_pointer_v =3D __is_pointer(_Tp); > +#else > template > - inline constexpr bool is_pointer_v =3D is_pointer<_Tp>::value; > + inline constexpr bool is_pointer_v =3D false; > +template > + inline constexpr bool is_pointer_v<_Tp*> =3D true; > +template > + inline constexpr bool is_pointer_v<_Tp* const> =3D true; > +template > + inline constexpr bool is_pointer_v<_Tp* volatile> =3D true; > +template > + inline constexpr bool is_pointer_v<_Tp* const volatile> =3D true; > +#endif > + > template > inline constexpr bool is_lvalue_reference_v =3D false; > template > -- > 2.42.0 >