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.129.124]) by sourceware.org (Postfix) with ESMTPS id AA3453857C45 for ; Thu, 13 Jul 2023 09:22:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AA3453857C45 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689240132; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=j3UtLSaoiznVCy5DBRWaB0KypBgU33KD+h4EHONOfPw=; b=g+oVtwu6vXzXlYWM/9IgMHGjEQUgO7qi/BT53On0vPCf7ZVPumLVzxulBYcWcZBL+SsDHv eY0BrwYOO6FPeb/rWyT7Guvgpgs7tCXBO5SIAX2zpqA4lB+jZoGZTCL0HQ+thZ15TxrRym DD8fsWLrArN3S6pg9DQ6LHfz7/TxeL8= Received: from mail-lj1-f198.google.com (mail-lj1-f198.google.com [209.85.208.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-437-IFy-WrgZM0WGltN2cFnHVA-1; Thu, 13 Jul 2023 05:22:10 -0400 X-MC-Unique: IFy-WrgZM0WGltN2cFnHVA-1 Received: by mail-lj1-f198.google.com with SMTP id 38308e7fff4ca-2b6fbef3087so4744871fa.0 for ; Thu, 13 Jul 2023 02:22:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689240129; x=1691832129; 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=j3UtLSaoiznVCy5DBRWaB0KypBgU33KD+h4EHONOfPw=; b=SIP2ROL4Pgt6qV1aV0BwvHBC4RiuFILA1/VB7kPmSEpiCq4tqEm1AhXaSLzd62KRBj RpMZJxhYsvx0jB/J1yj1wYHracCI2U5esdee3SN+mRTUbJ60S4FEtbIGoxcFdgvGkwsS FIzVQ5WFUv6L8qVYKQhHsth9Ngufu3pMqlNAHU4U6RkF7SXP+IercZSA175Qpr9aNuXI 6sO8xlqgSe+7MjEMJbsm9xMyqDD+hAfsg5Wtq5YwVsUt/oVgboK/KBuL352Ign48nFRC wrszasqhObDXYF8zBBQMVTH6crnR5tV6qmpD5vyW0e2RzwCDtwXC2IiStVPO90AE2zL1 66yQ== X-Gm-Message-State: ABy/qLaNDOsi2wV+SrIO1xWgpccsPwlgj/nvO4cvAyTOCBR0KJKip0Wp Dq/PfKL4sWI0YnBG1QcriPPWwf/aOCGVU+VjWSAyvW/FMS4IuUUU2bgIbmhIwqkWaMyNAU8ABSk kDhpdcf1SugfAKsnDiNX/dckgJR1kg/0= X-Received: by 2002:a2e:868a:0:b0:2b6:9ab8:9031 with SMTP id l10-20020a2e868a000000b002b69ab89031mr980919lji.16.1689240129328; Thu, 13 Jul 2023 02:22:09 -0700 (PDT) X-Google-Smtp-Source: APBJJlG5mqkIzqMO6TXpA7eIfmHr9FC6M3H1pLLVB2AUFjniMmY5/V2RijI95am4jUh+kboU3T9SfjqdrpQHCOcARfo= X-Received: by 2002:a2e:868a:0:b0:2b6:9ab8:9031 with SMTP id l10-20020a2e868a000000b002b69ab89031mr980896lji.16.1689240128985; Thu, 13 Jul 2023 02:22:08 -0700 (PDT) MIME-Version: 1.0 References: <20230710052310.48116-1-kmatsui@gcc.gnu.org> <20230710053828.49793-1-kmatsui@gcc.gnu.org> In-Reply-To: From: Jonathan Wakely Date: Thu, 13 Jul 2023 10:21:57 +0100 Message-ID: Subject: Re: [PATCH v2 1/2] c++, libstdc++: implement __is_pointer built-in trait To: Ken Matsui Cc: Ken Matsui , gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE 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 Wed, 12 Jul 2023 at 21:42, Ken Matsui wrote: > > On Wed, Jul 12, 2023 at 3:01=E2=80=AFAM Jonathan Wakely wrote: > > > > On Mon, 10 Jul 2023 at 06:51, Ken Matsui via Libstdc++ > > wrote: > > > > > > Hi, > > > > > > Here is the benchmark result for is_pointer: > > > > > > https://github.com/ken-matsui/gcc-benches/blob/main/is_pointer.md#sun= -jul--9-103948-pm-pdt-2023 > > > > > > Time: -62.1344% > > > Peak Memory Usage: -52.4281% > > > Total Memory Usage: -53.5889% > > > > Wow! > > > > Although maybe we could have improved our std::is_pointer_v anyway, lik= e so: > > > > template > > 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; > > > > I'm not sure why I didn't already do that. > > > > Could you please benchmark that? And if it is better than the current > > impl using is_pointer<_Tp>::value then we should do this in the > > library: > > > > #if __has_builtin(__is_pointer) > > template > > inline constexpr bool is_pointer_v =3D __is_pointer(_Tp); > > #else > > template > > 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 > > Hi Fran=C3=A7ois and Jonathan, > > Thank you for your reviews! I will rename the four underscores to the > appropriate name and take a benchmark once I get home. > > If I apply your change on is_pointer_v, is it better to add the > `Co-authored-by:` line in the commit? Yes, that would be the correct thing to do (although in this case the change is small enough that I don't really care about getting credit for it :-)