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 8A0C9384D1AA for ; Wed, 7 Sep 2022 08:19:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8A0C9384D1AA 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=1662538791; 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=yqSVnozndzeQSeBxOdDX6mpLb43AQ2fS9QFusWMENTQ=; b=DeF4Gz+ci4oV+VFFHvQcEMSwSGn0jw/hsHMH9qVCMONjrSm6Oi3rwm7f5MpZGw6nK6H9Lv ncH+Gn1FppHmIZaCa4x7j6yA3GB+eKt5Anou+1cX4j2iZK14eAVUKq+p269xynsi/30sCS gtrbNNHGK2lxxwl3FWv+ZZIw9TuYx+I= Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-653-foU-xPq2ON6atgENkEhsTg-1; Wed, 07 Sep 2022 04:19:50 -0400 X-MC-Unique: foU-xPq2ON6atgENkEhsTg-1 Received: by mail-qt1-f197.google.com with SMTP id e30-20020ac8011e000000b00342f61e67aeso11102621qtg.3 for ; Wed, 07 Sep 2022 01:19:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=yqSVnozndzeQSeBxOdDX6mpLb43AQ2fS9QFusWMENTQ=; b=H0JdziM9jY2Vv/E5PlvZGZE6Yh+Sk92TBkdqY/GpvNGtmifXUxP2xy+Bu6Ga8G/pAo hytnVkmUFOKIiwu3/zQwiiNIL/QdfvZJd20dBoQLNGjse8mpguLLAir8oT/rohXNp3v4 BghxQYBkFTEz3Zr5TubNosqc7RKia+HtR55FleGdzjM5yxJAW6pT8k7Zg/cuDfYCN8Me piNDsBMs6pRu5Iu+gAaKvAMgfxKNTzvl8xDjAnpSLLSmLLhXexhg2jClWOkbH0nejEjz zUfifmKihd8Ce08MkhIOHANnCYytts4pgmpc22z/XahuNtj31/pBaG+kpTb3yGLcbVqv Ihwg== X-Gm-Message-State: ACgBeo1l64ImZm2Nrhwl/+lfiKpmqslFm5+g+EbbcvYl5IGBjJS8RbNn 8fqecKGxebCRGfcACUYxKcBJejtJzQEVH0Ita2A9higjpO8lmjRfmbo2uTNcydFSt2uImAcmC/h LxThbnLI+zHnYw6i5DjaKK3TCi6YFSylJfA== X-Received: by 2002:a05:620a:884:b0:6bc:2056:1005 with SMTP id b4-20020a05620a088400b006bc20561005mr1761353qka.293.1662538790239; Wed, 07 Sep 2022 01:19:50 -0700 (PDT) X-Google-Smtp-Source: AA6agR5Q6sC+rNQtoeiXjc3NoBQTmYep2IcovlfrxW3XRx+Iw6G6WXvjQH0VJK7wvbbuZs/Y/9lshkkhCaL9RcmjsTM= X-Received: by 2002:a05:620a:884:b0:6bc:2056:1005 with SMTP id b4-20020a05620a088400b006bc20561005mr1761348qka.293.1662538790059; Wed, 07 Sep 2022 01:19:50 -0700 (PDT) MIME-Version: 1.0 References: <20220907004542.288365-1-ppalka@redhat.com> In-Reply-To: <20220907004542.288365-1-ppalka@redhat.com> From: Jonathan Wakely Date: Wed, 7 Sep 2022 09:19:39 +0100 Message-ID: Subject: Re: [PATCH 1/2] libstdc++: Optimize is_void and is_null_pointer To: Patrick Palka Cc: 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=-6.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,KAM_SHORT,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE 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: On Wed, 7 Sept 2022 at 01:46, Patrick Palka via Libstdc++ wrote: > > Instead of defining these in terms of a helper class template > and the relatively expensive __remove_cv_t, just declare four > explicit specializations of the main template, one for each choice > of cv-quals. > > Tested on x86_64-pc-linux-gnu, does this look OK for trunk? Yes, and we should do the same for is_void_v and is_null_pointer_v. Even though the class templates they instantiate will be cheaper now, they can still avoid any class template instantiation. > The is_void change alone reduces memory usage for join.cc by > almost 1%. Also in my queue of trait refactoring, but I haven't tested if these are worth doing yet: template struct is_object : is_const::type { }; template<> struct is_object : false_type { }; template<> struct is_object : false_type { }; // and so on for volatile and const volatile And we could define is_object_v as simply is_const_v && is_void_v. Improving is_object should benefit and also the is_scalar change proposed at https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96710#c2