From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-vk1-xa2b.google.com (mail-vk1-xa2b.google.com [IPv6:2607:f8b0:4864:20::a2b]) by sourceware.org (Postfix) with ESMTPS id 9EEBE3858C1F for ; Wed, 12 Jul 2023 20:42:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9EEBE3858C1F 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 Received: by mail-vk1-xa2b.google.com with SMTP id 71dfb90a1353d-48133dc9820so360537e0c.3 for ; Wed, 12 Jul 2023 13:42:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cs.washington.edu; s=goo201206; t=1689194559; x=1691786559; 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=rJeCZNLAGSKcQhGnzOVdwHlco97Q+Prq3Kcs1qMRU80=; b=job3WpMFeza2+0eDCBSAEKn9EpujfGiqESuPPKCOenRGq7zd+EWrvHilCU10e+t+KR BAbDGdt5b9HsZBmx3aMDJF/9gMIIyHoo8KZj81mSdKXQQbPhzKj2Jm0FB8kF74omtSb5 N+8qCruhvfAmv811wWtL33j8EI+gdByph9vp0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689194559; x=1691786559; 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=rJeCZNLAGSKcQhGnzOVdwHlco97Q+Prq3Kcs1qMRU80=; b=g5VaQBUXYKyp7Xds57cKUddPCdem0fLzKBeQagY1VWYViA/JQ5Szlg5MXIstXUw3TY NvEr+Zjpvp49uFKePvmD587WuP2l0BFUntWavVYqXzhRKNi37+wQyNkYDffv6meZ0aFg pWSZEkeIYCJR/Spcdf5ANikOOhGh6gE/c5ta+Ok7ESKNP/lTI/nlG2qAtnmi8Z6mzwxW AIwOF0FJLukr6ZPy6Tb9JM9YmGjHfk38WfXFhLJWBXzvwNyRhUb9SriIj9HZXFfRsQgs loNRSOqpmGIM63TLyueqF4NB2e6W+6f2p4lImhHJe6470/6HzSUZ29wXHsgzpAY4ZZ4I q4mQ== X-Gm-Message-State: ABy/qLbewvUeStqXGwjRw2QmpGo6M7O6SqbmVEJ/Ienvb0mFNFvpckK9 qMuk97iuh+HScywcUFgFSXswRedtX2TojSe4TZHdRA== X-Google-Smtp-Source: APBJJlEgtGg7ejTnfRyIEAUImNBZb21bdUq4wqUiMBr2ttYCeATOv2XvwxFVhAeJx3aY3ePd8xhLLw8IeHE9wEw8SX8= X-Received: by 2002:a1f:e683:0:b0:471:53e9:376d with SMTP id d125-20020a1fe683000000b0047153e9376dmr7257107vkh.4.1689194559463; Wed, 12 Jul 2023 13:42:39 -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: Ken Matsui Date: Wed, 12 Jul 2023 13:42:23 -0700 Message-ID: Subject: Re: [PATCH v2 1/2] c++, libstdc++: implement __is_pointer built-in trait To: Jonathan Wakely 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=-2.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,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, 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-j= ul--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, like = 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?