From patchwork Wed Feb 15 20:49:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matthias Kretz X-Patchwork-Id: 57719 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp410673wrn; Wed, 15 Feb 2023 12:51:12 -0800 (PST) X-Google-Smtp-Source: AK7set8/VrWQCBILwXsnQOOPGidvSsNbI9PvCgPv44yLOp8v+9pfHTTI+Pv8VikCUS1qvw0JgVqz X-Received: by 2002:a05:6402:1517:b0:4ac:d3bc:cb0d with SMTP id f23-20020a056402151700b004acd3bccb0dmr3938069edw.3.1676494271956; Wed, 15 Feb 2023 12:51:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676494271; cv=none; d=google.com; s=arc-20160816; b=EdjZSdfttjJePFWbM33TpiJPPdBdywzhuVZfJpCjozxEWvGRwoBED4iP2+AEgDKk1d a7OGLrrO0Liq+V7SfucYW/LErZH2Sl8LviwLvng0w80RdtgBPo+yL+1OcdqbrGu6WU3K 16ACuMIUrV0tAtdoYX5B6BFWf9xnDfNeURpVXxkxBSg0dQArtWdHiEigBr41om19byqk UkeY59BybvBgmicwNVTHZFZ8f0BtCExcWWsTvqiinp6/XPhP8R/84UT5qdF+TUiQKQcM aigz1O/e7hRAdP6hauq7vpVLsOT8JumUZrI1sbJDZ9dglzNKgunPeqtP3oy7Wt/tATL0 ZJjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:references:in-reply-to :organization:message-id:date:subject:to:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=adsKN4WaAWVPV63CWQYL28a1za4vKMQ5h3svhN7NFJM=; b=aqnIuHlJBnW92ydNfAgpa3JSB7G6DZML5D7A0e8kp3i6RZwBiUPM1+Dj1f1fm0qWu/ WOc3gLNO903O4gpPvBVzFFtRbPcwCv8aWFBAS8HJSTXwk+UauFnkH03f+53sF9kwGk9E UklVWSO+EY96Eb+OpJ5ejweJM8QIBEDpjHxE50DhRJK79ijennHe5oYioWpjBVnQiLr+ YNuQl2NgyBqNQvCRuhxH+tGoPgPxdQKK8gphb4NfazOGzuOhuPGmAnXLY4lhU/CM+Fue 6+eJTCu+E1ZB6FBb5NjXPEfB5qji81R5k8NEmcywOqIMW0K0Gvi3jyHKgdXp+7TUlzQ7 XZnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=RvXTEAFr; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id i4-20020aa7c704000000b004acb603a70esi13644318edq.230.2023.02.15.12.51.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Feb 2023 12:51:11 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=RvXTEAFr; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C10AF3881D07 for ; Wed, 15 Feb 2023 20:50:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C10AF3881D07 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1676494227; bh=adsKN4WaAWVPV63CWQYL28a1za4vKMQ5h3svhN7NFJM=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=RvXTEAFrdAorgKKlACICQE/MSSbe56R749YaiEfU20hny2Qc1DgzHl5n/JvKHSnnt PxhhbN8u4l3w3kmTSP0HYGn0+8XgvcqTXNbsHqTWvJAmdhpJX41Sloc9mbV9OlTxwi a+4Y8HNfzA84EiZhUjqH25nnCR/TRPFvSSaLc9wI= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from lxmtout2.gsi.de (lxmtout2.gsi.de [140.181.3.112]) by sourceware.org (Postfix) with ESMTPS id A1DDC3857437; Wed, 15 Feb 2023 20:49:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A1DDC3857437 Received: from localhost (localhost [127.0.0.1]) by lxmtout2.gsi.de (Postfix) with ESMTP id D69A3202AD62; Wed, 15 Feb 2023 21:49:37 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at lxmtout2.gsi.de Received: from lxmtout2.gsi.de ([127.0.0.1]) by localhost (lxmtout2.gsi.de [127.0.0.1]) (amavisd-new, port 10024) with LMTP id NONIUnXqFl2R; Wed, 15 Feb 2023 21:49:37 +0100 (CET) Received: from srvEX6.campus.gsi.de (unknown [10.10.4.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lxmtout2.gsi.de (Postfix) with ESMTPS id B5F33202AD51; Wed, 15 Feb 2023 21:49:37 +0100 (CET) Received: from minbar.localnet (140.181.3.12) by srvEX6.campus.gsi.de (10.10.4.96) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.21; Wed, 15 Feb 2023 21:49:37 +0100 To: , Subject: [PATCH 1/7] libstdc++: Ensure __builtin_constant_p isn't lost on the way Date: Wed, 15 Feb 2023 21:49:36 +0100 Message-ID: <21793652.EfDdHjke4D@minbar> Organization: GSI Helmholtz Centre for Heavy Ion Research In-Reply-To: <3238840.44csPzL39Z@minbar> References: <3238840.44csPzL39Z@minbar> MIME-Version: 1.0 X-Originating-IP: [140.181.3.12] X-ClientProxiedBy: srvEX7.Campus.gsi.de (10.10.4.97) To srvEX6.campus.gsi.de (10.10.4.96) X-Spam-Status: No, score=-10.0 required=5.0 tests=BAYES_00, BODY_8BITS, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Matthias Kretz via Gcc-patches From: Matthias Kretz Reply-To: Matthias Kretz Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757931657532942977?= X-GMAIL-MSGID: =?utf-8?q?1757931657532942977?= The more expensive code path should only be taken if it can be optimized away. Signed-off-by: Matthias Kretz libstdc++-v3/ChangeLog: * include/experimental/bits/simd.h (_SimdWrapper::_M_is_constprop_none_of) (_SimdWrapper::_M_is_constprop_all_of): Return false unless the computed result still satisfies __builtin_constant_p. --- libstdc++-v3/include/experimental/bits/simd.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) -- ────────────────────────────────────────────────────────────────────────── Dr. Matthias Kretz https://mattkretz.github.io GSI Helmholtz Centre for Heavy Ion Research https://gsi.de stdₓ::simd ────────────────────────────────────────────────────────────────────────── diff --git a/libstdc++-v3/include/experimental/bits/simd.h b/libstdc++-v3/include/experimental/bits/simd.h index e76f4781fa6..3de966bbf22 100644 --- a/libstdc++-v3/include/experimental/bits/simd.h +++ b/libstdc++-v3/include/experimental/bits/simd.h @@ -2673,7 +2673,8 @@ template else __execute_n_times<_Width>( [&](auto __i) { __r &= _M_data[__i.value] == _Tp(); }); - return __r; + if (__builtin_constant_p(__r)) + return __r; } return false; } @@ -2693,7 +2694,8 @@ template else __execute_n_times<_Width>( [&](auto __i) { __r &= _M_data[__i.value] == ~_Tp(); }); - return __r; + if (__builtin_constant_p(__r)) + return __r; } return false; }