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: 66708 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AED4D3850438 for ; Tue, 21 Mar 2023 17:05:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AED4D3850438 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1679418349; 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=ezvDBOSsOjzvFUbs6NCCzg5tI/CxHtwUcNPpYVEO60XzDLV4ZrKTdcQLcLyxgxJ4k ytFmhmmZ+l327ZSOQLbKLmfNTJpbpFb2c6pJ9XTEfAjFjxgzbvc31H5rJAM0RpqoKi NbR36L8Hj1UwJCXUNNpmJxAoabUHYGSFcSScUJ40= 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+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" 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 {{{