From patchwork Tue Mar 21 17:05:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matthias Kretz X-Patchwork-Id: 72943 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp1897752wrt; Tue, 21 Mar 2023 10:06:40 -0700 (PDT) X-Google-Smtp-Source: AK7set9GbeYFV1DvA3Hp2naKf6zbsJiXxBg+MEvxWxEWSOc9RbOhNL7CvPJtQioWWgmgZjt47EHZ X-Received: by 2002:aa7:c393:0:b0:4fb:395a:6aa4 with SMTP id k19-20020aa7c393000000b004fb395a6aa4mr3839599edq.31.1679418399987; Tue, 21 Mar 2023 10:06:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679418399; cv=none; d=google.com; s=arc-20160816; b=hDW79G4ZVQvyL4G0kPi+qcczORD+S7D7v2XTAl39MfPtTfwbAXGOgfjUBnmOoRRyU9 JSmnBe6y4L64mhpTPqM5Q+9yGb8b2+heMED9QbZ8Ywme2XO41phmbZYpLOi/K8xGLkXj jpyOlzuudb6bIr8k8D64UotGP0U9cy7yl3us0/Q8XIdF3nfm6F/Fz6Q9TaqG1S+Mm13X Yibe5NZA8rW8QOySu9bkAE5qiWpL6hyB05uYys3WHBHHlrvtH+OlYINsQOmc3IU6KM2R fvRCeY7KKnxwitk+NViSMtJnDzSDmqsP94toMrcC9PDO7gi+phBVcENrQPVL0OaJLk6U hnSw== 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:organization:message-id:date :subject:to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=y5XhY4vTolPU0egUh+Et+2Oe+Y/MzZsB3ro5z6Yyy7w=; b=vIo33uUfv2k7cWdigtMMHKWDdGlt5IbWWYlz2NOrYDCuzfDdoIS9O53jpOfEa+F4Mw ViUPSCI4uTR2zXhE5Cle8A4xOrUqjqDOG8U1luoUH79Bf6Pe8+yeg+O7UFc9zm0zG3YO 8tdIBNCNQyeLpbD8NNexy2OlNWHd1CuETjTHCxZ4Y23O1NrUA0J18HilTslht4M/MLfi jinQOyduGUa7nEbpAOU3LD9t/v5SdyuDDKmskbJGY3MlnkJeilMItLzdXtdpzadJF05V l4UP8HOv2e77yy4tDAdlU9C3czpkRaaInO+x1F0Lr+X/d7f0K2MRWGFBNZX+0MoMw/U6 AhnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=dEzMNLNF; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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 (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id ue6-20020a170907c68600b009321def4b92si5106989ejc.333.2023.03.21.10.06.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Mar 2023 10:06:39 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=dEzMNLNF; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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 26DBB38493FF for ; Tue, 21 Mar 2023 17:06:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 26DBB38493FF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1679418365; bh=y5XhY4vTolPU0egUh+Et+2Oe+Y/MzZsB3ro5z6Yyy7w=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=dEzMNLNFPyEUbnIiNJdIleBvbBhoUzEAPsky+i1tgWIjED83Yjaxho5qpx06JWiBF +xuCa32p1tmKPkzAEx+Ciq0i3jozcM3e8Ay4uVDNS/RQg6bDGcK1912UMwEDoy4PnZ KMGgt3xTcXUPQhX4o3GTXLjGQrluMKAWV8wAQ7zo= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from lxmtout1.gsi.de (lxmtout1.gsi.de [140.181.3.111]) by sourceware.org (Postfix) with ESMTPS id 9FEE63858C5F; Tue, 21 Mar 2023 17:05:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9FEE63858C5F Received: from localhost (localhost [127.0.0.1]) by lxmtout1.gsi.de (Postfix) with ESMTP id C0D872051042; Tue, 21 Mar 2023 18:05:19 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at lxmtout1.gsi.de Received: from lxmtout1.gsi.de ([127.0.0.1]) by localhost (lxmtout1.gsi.de [127.0.0.1]) (amavisd-new, port 10024) with LMTP id VFTzus3kIip1; Tue, 21 Mar 2023 18:05:19 +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 lxmtout1.gsi.de (Postfix) with ESMTPS id A60F32051040; Tue, 21 Mar 2023 18:05:19 +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.26; Tue, 21 Mar 2023 18:05:19 +0100 To: , Subject: [PATCH] libstdc++: Skip integer division optimization for Clang Date: Tue, 21 Mar 2023 18:05:18 +0100 Message-ID: <7568297.R56niFO833@minbar> Organization: GSI Helmholtz Centre for Heavy Ion Research MIME-Version: 1.0 X-Originating-IP: [140.181.3.12] X-ClientProxiedBy: srvEX6.Campus.gsi.de (10.10.4.96) To srvEX6.campus.gsi.de (10.10.4.96) X-Spam-Status: No, score=-10.1 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?1760997828370383083?= X-GMAIL-MSGID: =?utf-8?q?1760997828370383083?= Tested on x86_64-pc-linux-gnu. --------- 8< ----------- Clang ICEs on _SimdImplX86::_S_divides. The function is only working around a missed optimization and not necessary for correctness. Therefore, don't use it for Clang. Signed-off-by: Matthias Kretz libstdc++-v3/ChangeLog: * include/experimental/bits/simd_detail.h: Don't define _GLIBCXX_SIMD_WORKAROUND_PR90993 for Clang. * include/experimental/bits/simd_x86.h (_S_divides): Remove check for __clang__. --- libstdc++-v3/include/experimental/bits/simd_detail.h | 2 ++ libstdc++-v3/include/experimental/bits/simd_x86.h | 4 ++-- 2 files 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_detail.h b/libstdc++-v3/include/experimental/bits/simd_detail.h index 49b94decf0a..1fb77866bb2 100644 --- a/libstdc++-v3/include/experimental/bits/simd_detail.h +++ b/libstdc++-v3/include/experimental/bits/simd_detail.h @@ -320,7 +320,9 @@ namespace experimental #endif // integer division not optimized +#ifndef __clang__ #define _GLIBCXX_SIMD_WORKAROUND_PR90993 1 +#endif // very bad codegen for extraction and concatenation of 128/256 "subregisters" // with sizeof(element type) < 8: https://godbolt.org/g/mqUsgM diff --git a/libstdc++-v3/include/experimental/bits/simd_x86.h b/libstdc++-v3/include/experimental/bits/simd_x86.h index 7b8f1c664b3..28ba344c2b2 100644 --- a/libstdc++-v3/include/experimental/bits/simd_x86.h +++ b/libstdc++-v3/include/experimental/bits/simd_x86.h @@ -1469,7 +1469,7 @@ _CsrGuard() [&__xf, &__yf](auto __i) _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA -> _SimdWrapper<_Float, __n_intermediate> { -#if !defined __clang__ && __GCC_IEC_559 == 0 +#if __GCC_IEC_559 == 0 // If -freciprocal-math is active, using the `/` operator is // incorrect because it may be translated to an imprecise // multiplication with reciprocal. We need to use inline @@ -1524,7 +1524,7 @@ _CsrGuard() */ return _Base::_S_divides(__x, __y); } - #endif // _GLIBCXX_SIMD_WORKAROUND_PR90993 +#endif // _GLIBCXX_SIMD_WORKAROUND_PR90993 // }}} // _S_modulus {{{