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 505AD3858C2C for ; Mon, 23 Oct 2023 17:00:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 505AD3858C2C 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 505AD3858C2C 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=1698080425; cv=none; b=m1FOlZfDAs2pJlOoVyQi5XGZ6JoIzyNWSoinet+N5ZanNUuQXHCTnsWKEi1SlCeFjp7orS0bW9VbaE/HmBeglvUBPxM5cfszSSteVPQOMyu2XKVKUQfHBp/wOJLkK9xiCWuKXMPPreshK3sCk+nAtq2MK+tjVw1jBtQeASBAvzg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698080425; c=relaxed/simple; bh=yqGDT2Iv3k2PTWUYfcEX6lxHb1MlS0l5MQEyaN8lDbw=; h=DKIM-Signature:From:Date:To:Subject:Message-ID:MIME-Version; b=foECwf8ge0KzHb7ZylTY1yA5r3TuuVTpf1vvL2biiH20GtH03WSAgtpPGGS9zHHWF2vqOnyXgWSOvk53So88ij0uqbGy5GF4dq6EeilS8UQbbX+QMMsA7VEIODtkn/bFNhn5c24CjHwU/+itt4yoEPAMFYBV7X2BCgwlf3A9XjQ= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698080423; 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=9hYqALdpuP2OISwXjjhrGmir+7/yNvF0DzuFQpxsyCM=; b=Nw+edGyBCyNwkzadcU3Jifd4Y7MnOKpIiHVPHfKFw3rgu52reE7przKYaVY5+lvJjcsvUI oPZdozH4uflR7//BzKXAe49URlBcnG/a8/5iiTDn/OhGk6HMfmUM9jTAdPDhy2wxroXGWQ KdIL1bUiKwHQd5UG/eejHi8nU5fmdbw= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-160-H7FuU5TrO5mTACHZgZJRNw-1; Mon, 23 Oct 2023 13:00:21 -0400 X-MC-Unique: H7FuU5TrO5mTACHZgZJRNw-1 Received: by mail-qk1-f198.google.com with SMTP id af79cd13be357-7788fa5f13cso684461685a.1 for ; Mon, 23 Oct 2023 10:00:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698080421; x=1698685221; 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=ZX9uMYClyH1tWP9p7/nQ7CXvEgUgJVhBtmj/zQy2wnc=; b=IVMgRzvaBzGsrugmggppA90X7P+p42n7Cxr2rBppmrN5JIdcLxA+XuoX9AXZDRR5L5 GUnM5ZBaEn7SeSRfQ9IIExwrWFCuTBwFCuEfgiuOZ6V2vqjUkfRDkhnW/w3OMD0FAw47 e07iahD6/SZZwS1D0RgXjjTjbVcKMcRDE1Kienv2byVBZ/fOKSTDCYdkLnIxexleOGKL KJfFTtj8+xaduXsZFiOTk4l7sSqFCvyvTIH950VECw1GTztY7dS6orgtPIao1egW48g8 LTMM5kpXvRUWlTUJWz/VqHimFZTUz4br99LBqjAwGSnVNmwIevZFpKKwDXN1DmsckHmT eGCw== X-Gm-Message-State: AOJu0Yyblgetot+Av4Nq73vxAD/m11+vC290QKjXl/DSNqIU06wLC53p +sRabimd6W4PQfVizIEyn3/HKyGuyXIQMvjEKyVV64TFSrnTYwRxjj0qpWKHgZBYHjQPJZ7hNnL t8gup3Xfi+5TAeWg= X-Received: by 2002:a05:620a:4509:b0:767:f178:b571 with SMTP id t9-20020a05620a450900b00767f178b571mr16888534qkp.10.1698080420910; Mon, 23 Oct 2023 10:00:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFbwQhQNhDIYFG3Q+/61p1EL99ahuYo2ps8DGk39iZRzqmkZST2cDQC9X/Kwv2S35jF4somgQ== X-Received: by 2002:a05:620a:4509:b0:767:f178:b571 with SMTP id t9-20020a05620a450900b00767f178b571mr16888502qkp.10.1698080420561; Mon, 23 Oct 2023 10:00:20 -0700 (PDT) Received: from [192.168.1.130] (ool-457670bb.dyn.optonline.net. [69.118.112.187]) by smtp.gmail.com with ESMTPSA id d16-20020a0cea90000000b0066d0f35554asm3007513qvp.79.2023.10.23.10.00.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 10:00:20 -0700 (PDT) From: Patrick Palka X-Google-Original-From: Patrick Palka Date: Mon, 23 Oct 2023 13:00:19 -0400 (EDT) To: Ken Matsui cc: Patrick Palka , gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org, Ken Matsui , Jonathan Wakely Subject: Re: [PATCH v23 31/33] libstdc++: Optimize std::is_pointer compilation performance In-Reply-To: Message-ID: References: <20231017113822.677344-1-kmatsui@gcc.gnu.org> <20231020135748.1846670-1-kmatsui@gcc.gnu.org> <20231020135748.1846670-32-kmatsui@gcc.gnu.org> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: multipart/mixed; boundary="8323329-536443616-1698080420=:986507" 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=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: This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323329-536443616-1698080420=:986507 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT On Sun, 22 Oct 2023, Ken Matsui wrote: > 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? The following workaround seems to make Clang happy: #include template struct __is_pointer : std::bool_constant { }; > > https://godbolt.org/z/PbxhYcb7q > > Sincerely, > Ken Matsui > > On Fri, Oct 20, 2023 at 7:12 AM Ken Matsui wrote: > > > > 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/include/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 = __is_pointer(_Tp) }; > > + }; > > +#else > > template > > struct __is_pointer > > { > > @@ -376,6 +383,7 @@ __INT_N(__GLIBCXX_TYPE_INT_N_3) > > enum { __value = 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]> = true; > > #endif > > > > +#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_pointer) > > +template > > + inline constexpr bool is_pointer_v = __is_pointer(_Tp); > > +#else > > template > > - inline constexpr bool is_pointer_v = is_pointer<_Tp>::value; > > + inline constexpr bool is_pointer_v = false; > > +template > > + inline constexpr bool is_pointer_v<_Tp*> = true; > > +template > > + inline constexpr bool is_pointer_v<_Tp* const> = true; > > +template > > + inline constexpr bool is_pointer_v<_Tp* volatile> = true; > > +template > > + inline constexpr bool is_pointer_v<_Tp* const volatile> = true; > > +#endif > > + > > template > > inline constexpr bool is_lvalue_reference_v = false; > > template > > -- > > 2.42.0 > > > > --8323329-536443616-1698080420=:986507--