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 6D8453858D3C for ; Wed, 8 Dec 2021 19:27:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6D8453858D3C Received: from mail-yb1-f200.google.com (mail-yb1-f200.google.com [209.85.219.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-554-4y-M9eB7PnmMbaYMJU2SUA-1; Wed, 08 Dec 2021 14:27:27 -0500 X-MC-Unique: 4y-M9eB7PnmMbaYMJU2SUA-1 Received: by mail-yb1-f200.google.com with SMTP id r18-20020a25ac52000000b005c9047c420bso6221243ybd.4 for ; Wed, 08 Dec 2021 11:27:27 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=iI4HGkhYdREeVyA69ZvvSeMb7TRkBLgRFysyhB01w4M=; b=3L+gEEZTVLsm8z03okQDCTJ/PeoYMyeepw7KjUxTnRWPKMvCU7s2pgEuDs+EBXlKyw DOL+T1obNb4anRREjJDj9VuAetY1232zVE9PaxgH5g2ms5Pp39kvXOOczLnYN/i+lPfD +B1hGw/qRWlj8PY0br9sLRQD+kwaaUbh3tXGWoM2gxDz5Z9k5Og1uAaDV6yzd9uuSpbw ft/049zZbnHGNMcCZfjm0+DT1j306/UVuKkXFQMxwsBZ/wq7eNmNZeW/ig8kHz4432Gq gmzbttAlhpuAR2/6XhpsmJEik6bd1lKA4Q/LtZ/K6ipfOq1kC+oPjY/NF1BxQ71CrLAn X/Jw== X-Gm-Message-State: AOAM530wf55CIkuo6oUcdk3bLOYloavgd5ZgNs8sCtePnOI4n2hZeLoz ZScV+3ymmCtSo3Aco+wJ2bsADD7yXv7qPi9QpmO0TWgTIAH7Ve4mjlOn//ZO0HnxoNLVsnpg5cx Yl7NOcc+kJ9XKjvWYSMioI50xebVXyeM= X-Received: by 2002:a05:6902:1501:: with SMTP id q1mr993923ybu.580.1638991646708; Wed, 08 Dec 2021 11:27:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJw87aY3ZfCCMA6ERrT/zGNXV+yA0UjS68jyuAorfCEJQpGRb/uQMrObfk9jt0cSI3wlccvM6YL8Sofbvm8eQCQ= X-Received: by 2002:a05:6902:1501:: with SMTP id q1mr993895ybu.580.1638991646531; Wed, 08 Dec 2021 11:27:26 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Jonathan Wakely Date: Wed, 8 Dec 2021 19:27:15 +0000 Message-ID: Subject: Re: [PATCH] libstdc++: Skip atomic instructions in _Sp_counted_base::_M_release when both counts are 1 To: Rainer Orth Cc: Jonathan Wakely via Gcc-patches , "libstdc++" 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=-7.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_NUMSUBJECT, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libstdc++@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++ mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Dec 2021 19:27:29 -0000 On Wed, 8 Dec 2021 at 19:21, Jonathan Wakely wrote: > > On Wed, 8 Dec 2021 at 19:17, Rainer Orth wrote: > > > > Hi Jonathan, > > > > > I've pushed this change to trunk now (it was posted and reviewed in > > > stage 1, I just didn't get around to pushing it until now). > > > > > > The final version of the patch is attached to this mail. > > > > unfortunately, it breaks Solaris/SPARC bootstrap: > > > > In file included from /var/gcc/regression/master/11.4-gcc-gas/build/spa= rc-sun-solaris2.11/sparcv9/libstdc++-v3/include/bits/shared_ptr.h:53, > > from /var/gcc/regression/master/11.4-gcc-gas/build/spa= rc-sun-solaris2.11/sparcv9/libstdc++-v3/include/memory:77, > > from /vol/gcc/src/hg/master/local/libstdc++-v3/include= /precompiled/stdc++.h:82: > > /var/gcc/regression/master/11.4-gcc-gas/build/sparc-sun-solaris2.11/spa= rcv9/libstdc++-v3/include/bits/shared_ptr_base.h: In member function 'void = std::_Sp_counted_base<_Lp>::_M_release() [with __gnu_cxx::_Lock_policy _Lp = =3D __gnu_cxx::_S_atomic]': > > /var/gcc/regression/master/11.4-gcc-gas/build/sparc-sun-solaris2.11/spa= rcv9/libstdc++-v3/include/bits/shared_ptr_base.h:329:26: error: right opera= nd of shift expression '(1 << 64)' is greater than or equal to the precisio= n 64 of the left operand [-fpermissive] > > 329 | =3D 1LL + (1LL << (__CHAR_BIT__ * sizeof(_Atomic_wo= rd))); > > | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~= ~~~ > > make[9]: *** [Makefile:1875: sparc-sun-solaris2.11/bits/stdc++.h.gch/O2= ggnu++0x.gch] Error 1 > > > > For 64-bit SPARC, _Atomic_word is long. > > Ah yes, so we need to disable this optimization. Patch coming up ... Gah, I remembered to check that: constexpr bool __double_word =3D sizeof(long long) =3D=3D 2 * sizeof(_Atomic_word); // The ref-count members follow the vptr, so are aligned to // alignof(void*). constexpr bool __aligned =3D __alignof(long long) <=3D alignof(void*)= ; if _GLIBCXX17_CONSTEXPR (__lock_free && __double_word && __aligned) But for C++11 and C++14 that is a normal runtime condition not if-constexpr, so the undefined shift still gets compiled, even though it can never be reached at runtime.