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 EAB4E3858D38 for ; Wed, 12 Jul 2023 10:01:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EAB4E3858D38 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=1689156099; 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=oTOGVR6pPqxpru1yoE1x/zFweTcrswg/hAd8obR6UwI=; b=CLxRyS4gdw6yhHsDVLeHqLvHS+7Rif609D7qt/FVwQI69zU0Cs/XjZWpVJlfv2tJW4dwC0 71+OQXVCYw5y3QwWVrzB1/ZcHAocXy742P2EpWM49w45xK2pawbu9kPjE4s0oTaBzrEwOK 77i26kmh6um7uPStJZ8H3GJBbKMiQYc= Received: from mail-lj1-f197.google.com (mail-lj1-f197.google.com [209.85.208.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-365-nuK-WbF6NeapGy_G22sjIw-1; Wed, 12 Jul 2023 06:01:37 -0400 X-MC-Unique: nuK-WbF6NeapGy_G22sjIw-1 Received: by mail-lj1-f197.google.com with SMTP id 38308e7fff4ca-2b70bfcd15aso53021091fa.0 for ; Wed, 12 Jul 2023 03:01:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689156096; x=1691748096; h=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=oTOGVR6pPqxpru1yoE1x/zFweTcrswg/hAd8obR6UwI=; b=hsTGBjrvD9vn4sxb82t1k7NzVY5lq5UQQEP4y7scBNeF7RA5NR0TzXMwtgXwWX0jjV tnxcq44hbjb2b+H3RleOFgYx810t3nn67Rrf97ZR1IJiRNmDj3f133JcdrpqqzjAfvCV ZrdUs+VHy6JyoLn/eTcyO70Dz9rZgr2DS+Zmbd7Re60qwEwxX4ZHEqYjX3U6AZGu+2qI BJ74eO9RbXj5sqNlEX24EAnUwljdhn2383OmZlLlYkzBYQbNkAU4h9BxshPCGzkFZS+q nqcVWROs4JjXq/Can5Iq5hCcs8MVPD8DRCxde17ouvj2wv1HGfG495qFx3AQjQAOWmN6 cPaw== X-Gm-Message-State: ABy/qLZcv2LSAIl4hcJddrtLsgcwnIP60OS8vGS8I7Of/VpcT2mopmRv NkvTITzImwiFf/SKuhYhzx8hCfhn+ooZsSMSC0Qv7DdwmWPwoXcWpDRSQJYlSj3BF1tpTwKqcja +VOSd+3WJYjoCF4CCusRqPurjXCkxR9E= X-Received: by 2002:a2e:7c1a:0:b0:2b6:fc88:3ee7 with SMTP id x26-20020a2e7c1a000000b002b6fc883ee7mr17707819ljc.13.1689156096351; Wed, 12 Jul 2023 03:01:36 -0700 (PDT) X-Google-Smtp-Source: APBJJlGqggKHEigQ63giHmGNQ4KtWn7d3BP3V1cbY19BfdL91fQM3hKXlFFXD393AaRIZU6hhuIkr77GWljJsQFli1g= X-Received: by 2002:a2e:7c1a:0:b0:2b6:fc88:3ee7 with SMTP id x26-20020a2e7c1a000000b002b6fc883ee7mr17707797ljc.13.1689156096035; Wed, 12 Jul 2023 03:01:36 -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: Wed, 12 Jul 2023 11:01:24 +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" 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 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, like so: template 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; 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 = __is_pointer(_Tp); #else template 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