From patchwork Tue May 3 02:00:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Oliva X-Patchwork-Id: 53409 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 EEDFC3857418 for ; Tue, 3 May 2022 02:00:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EEDFC3857418 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1651543243; bh=FOMQ2C/S3JEq+wBaTf/pWuPwadVjbwpeOQYqth0ujNw=; h=To:Subject:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=PVF1XsgYVE6Wb98fRDE2imqOA66xICQXbkzoyr8A2Tq/wNam2T9nyCb945iAOwsW7 slrTUxumVRryYJARShQDJrACIf9UkAUDMSPgLdzcDSrbuC2y9mzu3byp9ieukHB9jb W0BqJuoZWsVNZprduW30MX0OLxubZh+V7Kl1jwIM= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from rock.gnat.com (rock.gnat.com [IPv6:2620:20:4000:0:a9e:1ff:fe9b:1d1]) by sourceware.org (Postfix) with ESMTPS id 7BB7C3857815; Tue, 3 May 2022 02:00:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7BB7C3857815 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 85C69116516; Mon, 2 May 2022 22:00:09 -0400 (EDT) X-Virus-Scanned: Debian amavisd-new at gnat.com Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 3oyGxZuNL8WI; Mon, 2 May 2022 22:00:09 -0400 (EDT) Received: from free.home (tron.gnat.com [IPv6:2620:20:4000:0:46a8:42ff:fe0e:e294]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by rock.gnat.com (Postfix) with ESMTPS id 49069116506; Mon, 2 May 2022 22:00:08 -0400 (EDT) Received: from livre (livre.home [172.31.160.2]) by free.home (8.15.2/8.15.2) with ESMTPS id 2432025H2679899 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 2 May 2022 23:00:02 -0300 To: Segher Boessenkool Subject: [PATCH v2] libstdc++: ppc: conditionalize vsx-only simd intrinsics Organization: Free thinker, does not speak for AdaCore References: <20220428130306.GS25951@gate.crashing.org> <20220502213619.GW25951@gate.crashing.org> Date: Mon, 02 May 2022 23:00:02 -0300 In-Reply-To: <20220502213619.GW25951@gate.crashing.org> (Segher Boessenkool's message of "Mon, 2 May 2022 16:36:19 -0500") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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: 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: Alexandre Oliva via Gcc-patches From: Alexandre Oliva Reply-To: Alexandre Oliva Cc: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org, David Edelsohn Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" On May 2, 2022, Segher Boessenkool wrote: > Send full patches always please. I'll try to remember that. In case I fail, I hope you won't mind too much reminding me. (You'd also asked me not to send patches as followups, but... revised versions of a patch still belong in the same thread, right?) Here's the updated full patch. I tried to find earlier references to this partial specialization of template struct __intrinsic_type in ChangeLogs, to no avail. (That was why I went for the more abstract ChangeLog entry before.) libstdc++: ppc: conditionalize vsx-only simd intrinsics From: Alexandre Oliva libstdc++'s bits/simd.h section for PPC (Altivec) defines various intrinsic vector types that are only available along with VSX: 64-bit long double, double, (un)signed long long, and 64-bit (un)signed long. experimental/simd/standard_abi_usable{,_2}.cc tests error out reporting the unmet requirements when the target cpu doesn't enable VSX. Make the reported instrinsic types conditional on VSX so that can be used on ppc variants that do not have VSX support. Regstrapping on powerpc64le-linux-gnu. Ok for trunk? gcc-12? gcc-11? for libstdc++-v3/ChangeLog * include/experimental/bits/simd.h [__ALTIVEC__]: Require VSX for double, long long, and 64-bit long intrinsic types. [__ALTIVEC__] (__intrinsic_type): Mention 128-bit in preexisting long double diagnostic, adjust no-VSX double diagnostic to cover 64-bit long double as well. --- libstdc++-v3/include/experimental/bits/simd.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/libstdc++-v3/include/experimental/bits/simd.h b/libstdc++-v3/include/experimental/bits/simd.h index 82e9841195e1d..349726a16d71c 100644 --- a/libstdc++-v3/include/experimental/bits/simd.h +++ b/libstdc++-v3/include/experimental/bits/simd.h @@ -2430,17 +2430,23 @@ template template <> \ struct __intrinsic_type_impl<_Tp> { using type = __vector _Tp; } _GLIBCXX_SIMD_PPC_INTRIN(float); +#ifdef __VSX__ _GLIBCXX_SIMD_PPC_INTRIN(double); +#endif _GLIBCXX_SIMD_PPC_INTRIN(signed char); _GLIBCXX_SIMD_PPC_INTRIN(unsigned char); _GLIBCXX_SIMD_PPC_INTRIN(signed short); _GLIBCXX_SIMD_PPC_INTRIN(unsigned short); _GLIBCXX_SIMD_PPC_INTRIN(signed int); _GLIBCXX_SIMD_PPC_INTRIN(unsigned int); +#if defined __VSX__ || __LONG_WIDTH__ == 32 _GLIBCXX_SIMD_PPC_INTRIN(signed long); _GLIBCXX_SIMD_PPC_INTRIN(unsigned long); +#endif +#ifdef __VSX__ _GLIBCXX_SIMD_PPC_INTRIN(signed long long); _GLIBCXX_SIMD_PPC_INTRIN(unsigned long long); +#endif #undef _GLIBCXX_SIMD_PPC_INTRIN template @@ -2450,10 +2456,11 @@ template static constexpr bool _S_is_ldouble = is_same_v<_Tp, long double>; // allow _Tp == long double with -mlong-double-64 static_assert(!(_S_is_ldouble && sizeof(long double) > sizeof(double)), - "no __intrinsic_type support for long double on PPC"); + "no __intrinsic_type support for 128-bit floating point on PPC"); #ifndef __VSX__ - static_assert(!is_same_v<_Tp, double>, - "no __intrinsic_type support for double on PPC w/o VSX"); + static_assert(!(is_same_v<_Tp, double> + || (_S_is_ldouble && sizeof(long double) == sizeof(double))), + "no __intrinsic_type support for 64-bit floating point on PPC w/o VSX"); #endif using type = typename __intrinsic_type_impl<