From patchwork Tue Mar 21 09:23:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matthias Kretz X-Patchwork-Id: 72782 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp1673800wrt; Tue, 21 Mar 2023 02:24:38 -0700 (PDT) X-Google-Smtp-Source: AK7set9FV0PXBY6UPGrBpamY5Z3kKftTvFfA9QVBjou8IpqEN1I0V4Z9J6Ie4coKsb6gTNxnqi/b X-Received: by 2002:a17:906:e2ca:b0:932:b7ce:2aaa with SMTP id gr10-20020a170906e2ca00b00932b7ce2aaamr2109540ejb.28.1679390678480; Tue, 21 Mar 2023 02:24:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679390678; cv=none; d=google.com; s=arc-20160816; b=AyYEjdPeLzNzajTo6C3ZIKhwEQZ1O55AM1KxEEWX4DfFk1quZKpUbIMmnGjWzKcBl1 r45gXNLNGxEdGIqAwngQas3AF/FX/mwl18DwyxT4nzFIO0NCMsMMyt6LBB0x1RXmBfF+ GMV6WVuwq52LzONGsfgtGiEVxtIjlyrjxidN/k9YlUNpbHctB5KmFiKmF91v4XJxiZm+ puNuFHDg+mDLwBPcs/Tg9J8IrQOE0iYUVUdDsoouPfS9c6QeBnL+z8xsrTe24BAQIT9o iQl0ES6jU4rvigTC+9ZuG+N/jNYx/Eg5wXrF0f5MZdFlg5bpJdh0kBiNgJ/pBc/LJMus LIJQ== 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=uxqPb3Vz6b7EDQIgenq5w0DQzFUjsT6u8sxUoZ57AWE=; b=Y50yGf2g7sCTSjHm9C01HDOnVXARVQOlBQ471NwyLMKWXbZSLBEeGaOdjbiQnBNnG0 IyvSSxkgpgNF+FV31+UEmpdCAA93BOYArg+0BuVyVel37hK1Q8zXoOCL42+8k6SZRxBk gLkcdRSrhCpK0w1Pt0+ALimy5w0/WK0az6ANuwoeoxp4okpZVgNJZt8im05w3tmPAq7A SQTry2BfS/+2cJfG7A5FCC5Na7W6p+DNw4JhgjTagqqa8GFIvNV/L+1CtSOkW9YGeWT8 0sGaLCw/FOApiBYdEzZD5ozykjY5TSLmNlrrGf8m9VYmKWcO36ScSUxHhXNVKCAHYwQO cw8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=vkjvvIek; 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 jy7-20020a170907762700b00932987332c3si7129190ejc.431.2023.03.21.02.24.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Mar 2023 02:24:38 -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=vkjvvIek; 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 CC033385B53C for ; Tue, 21 Mar 2023 09:23:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CC033385B53C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1679390636; bh=uxqPb3Vz6b7EDQIgenq5w0DQzFUjsT6u8sxUoZ57AWE=; 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=vkjvvIek5UQFQIe127RDGkLCDoZdSQ46/dc82/o5qIz/2hhTPuzeI7N2IuHL6B+IQ 4lBzQIeSBhJiy6Ywya5jXWYpJLso7GaDm6GtWIsbAE4Nw62CzaIRM7/tM7R2zglWQq qZlgfI6v4AsA8c2Rx+2v6qceXY8dUjE1ccHRndws= 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 DF22C385B51C; Tue, 21 Mar 2023 09:23:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DF22C385B51C Received: from localhost (localhost [127.0.0.1]) by lxmtout2.gsi.de (Postfix) with ESMTP id 138CC203E7FE; Tue, 21 Mar 2023 10:23:07 +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 nGSHoG0UtgaN; Tue, 21 Mar 2023 10:23:06 +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 E7A40203E7FC; Tue, 21 Mar 2023 10:23:06 +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.25; Tue, 21 Mar 2023 10:23:06 +0100 To: , Subject: [PATCH 1/2] libstdc++: Fix simd test compilation with Clang Date: Tue, 21 Mar 2023 10:23:01 +0100 Message-ID: <12217370.T7Z3S40VBb@minbar> Organization: GSI Helmholtz Centre for Heavy Ion Research In-Reply-To: <6895974.e9J7NaK4W3@minbar> References: <6895974.e9J7NaK4W3@minbar> MIME-Version: 1.0 X-Originating-IP: [140.181.3.12] X-ClientProxiedBy: srvEX8.Campus.gsi.de (10.10.4.160) 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?1760968759754210021?= X-GMAIL-MSGID: =?utf-8?q?1760968759754210021?= Signed-off-by: Matthias Kretz libstdc++-v3/ChangeLog: * testsuite/experimental/simd/tests/operators.cc: Clang doesn't define __GCC_IEC_559. Use __STDC_IEC_559__ instead. --- .../testsuite/experimental/simd/tests/operators.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) -- ────────────────────────────────────────────────────────────────────────── Dr. Matthias Kretz https://mattkretz.github.io GSI Helmholtz Centre for Heavy Ion Research https://gsi.de stdₓ::simd ────────────────────────────────────────────────────────────────────────── diff --git a/libstdc++-v3/testsuite/experimental/simd/tests/operators.cc b/libstdc++-v3/testsuite/experimental/simd/tests/operators.cc index c4d91fa5d2b..72af7061c73 100644 --- a/libstdc++-v3/testsuite/experimental/simd/tests/operators.cc +++ b/libstdc++-v3/testsuite/experimental/simd/tests/operators.cc @@ -211,7 +211,14 @@ test() } // divides - constexpr bool is_iec559 = __GCC_IEC_559 >= 2; + constexpr bool is_iec559 = +#ifdef __GCC_IEC_559 + __GCC_IEC_559 >= 2; +#elif defined __STDC_IEC_559__ + true; +#else + false; +#endif if constexpr (std::is_floating_point_v && !is_iec559) { // avoid testing subnormals and expect minor deltas for non-IEC559 float V x = 2; From patchwork Tue Mar 21 09:23:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matthias Kretz X-Patchwork-Id: 72783 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp1673827wrt; Tue, 21 Mar 2023 02:24:44 -0700 (PDT) X-Google-Smtp-Source: AK7set9uF/ybKOwmmYZkl5JwbFMI2gQ7jNPdDy/T2ffmLEFrsp5j6BH0vAE5v3NoikWo3W8I6mDI X-Received: by 2002:a17:906:ce32:b0:939:7260:7f7e with SMTP id sd18-20020a170906ce3200b0093972607f7emr2458573ejb.49.1679390683969; Tue, 21 Mar 2023 02:24:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679390683; cv=none; d=google.com; s=arc-20160816; b=Q5Zg4Nah0U+B9uXXclp2i9IpnZBcC7LkakFKdmw3lMwL/6Z0oXquifew682hfeWjN5 +tdoytXpagu+fxrkrEp0wMrCHvCODMzc85LlghIbeclc+LtN5Ne3ZvgDxN+vtbGxReM+ dhRdWvAuJLToNgDxibQk1iPggk3TkusATasv6lAucUwBTI03v+S8cRAA8jbhQCc8+zp6 KlI0TNWqBaRZ6WEijSF5M+DrMvw1BTyZ+RPKV656I0BuwNLCcb6/U3GQOiW2BjFToKkb zdbxqUUPJnbXeC5/gWqeBw6lDIJahYN9fV/XvQUE9ujnOs+KPbwZNRg2mCfvsRLfC3bm C+Pg== 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=4v/zNZH62BXcZBJYxtE8AU/QA4C8t8WGz/2DT9tpDXg=; b=yAY8D9pg4VJcVHYco8jbFYGCy4pAvMQFnCXrfJ9gGTPvJ7lNaymOzvJDBikJOp271H NZQ3BkM8DseVLYA7kiquC9/eN5i3FvOEW+oGyypk4dhgFkN7gVgkC1tR4zRqTipIP+3D +l6D0Mk1oUfjY3AU421PrwcuYtHtuGFdUxYO32mx8s93u4/1BRTGI0JnfIqEZmPKtg17 k+kvzMML4FTA3G7topybK9EiFSzQqn7nnLeaNT2YqyGtGZoLF4kkOBs/h+hIVDSfWTa3 0qVZBtMhRO5RKU6pEzNxPYDaN4IvN17Vo3B3APw4Tvwd/NMlKGjdjAtRpFo+9MxOICPy 5Dmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=mOzxCghK; 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 a6-20020a170906190600b00931f8f04e64si11561088eje.840.2023.03.21.02.24.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Mar 2023 02:24:43 -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=mOzxCghK; 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 9DFFF384D16D for ; Tue, 21 Mar 2023 09:24:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9DFFF384D16D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1679390641; bh=4v/zNZH62BXcZBJYxtE8AU/QA4C8t8WGz/2DT9tpDXg=; 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=mOzxCghKE7je4YDkiDbgvZLVfqXLtS/d6Uah8v/3veS9RChpl59h3c+lba0mP+mos Fyuk2PJ8JUkOJyKLhtLt6QfTGUpaV5dGmfAPWBN57xeyxTlano77EYERnUmlggk0UM NUxiRnLpTnuHCS/jewamcUa0uNCyulxDMjDoj/qE= 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 738523850201; Tue, 21 Mar 2023 09:23:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 738523850201 Received: from localhost (localhost [127.0.0.1]) by lxmtout2.gsi.de (Postfix) with ESMTP id ACB95203E804; Tue, 21 Mar 2023 10:23:11 +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 0KZ7aPrQrJW7; Tue, 21 Mar 2023 10:23:11 +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 8CB03203E7FC; Tue, 21 Mar 2023 10:23:11 +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.25; Tue, 21 Mar 2023 10:23:11 +0100 To: , Subject: [PATCH 2/2] libstdc++: Fix simd compilation with Clang Date: Tue, 21 Mar 2023 10:23:10 +0100 Message-ID: <25835488.EfDdHjke4D@minbar> Organization: GSI Helmholtz Centre for Heavy Ion Research In-Reply-To: <6895974.e9J7NaK4W3@minbar> References: <6895974.e9J7NaK4W3@minbar> MIME-Version: 1.0 X-Originating-IP: [140.181.3.12] X-ClientProxiedBy: srvex5.Campus.gsi.de (10.10.4.95) 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?1760968765894033249?= X-GMAIL-MSGID: =?utf-8?q?1760968765894033249?= Clang fails to compile some constant expressions involving simd. Therefore, just disable this non-conforming extension for clang. Fix AVX512 blend implementation for Clang. It was converting the bitmask to bool before, which is obviously wrong. Instead use a Clang builtin to convert the bitmask to vector-mask before using a vector blend ?:. A similar change is required for the masked unary implementation, because the GCC builtins do not exist on Clang. Signed-off-by: Matthias Kretz libstdc++-v3/ChangeLog: * include/experimental/bits/simd_detail.h: Don't declare the simd API as constexpr with Clang. * include/experimental/bits/simd_x86.h (__movm): New. (_S_blend_avx512): Resolve FIXME. Implement blend using __movm and ?:. (_SimdImplX86::_S_masked_unary): Clang does not implement the same builtins. Implement the function using __movm, ?:, and - operators on vector_size types instead. --- .../include/experimental/bits/simd_detail.h | 2 +- .../include/experimental/bits/simd_x86.h | 59 +++++++++++++++++-- 2 files changed, 56 insertions(+), 5 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 30cc1ef0eef..f3745bf3e4c 100644 --- a/libstdc++-v3/include/experimental/bits/simd_detail.h +++ b/libstdc++-v3/include/experimental/bits/simd_detail.h @@ -267,7 +267,7 @@ namespace experimental #define _GLIBCXX_SIMD_IS_UNLIKELY(__x) __builtin_expect(__x, 0) #define _GLIBCXX_SIMD_IS_LIKELY(__x) __builtin_expect(__x, 1) -#if defined __STRICT_ANSI__ && __STRICT_ANSI__ +#if (defined __STRICT_ANSI__ && __STRICT_ANSI__) || defined __clang__ #define _GLIBCXX_SIMD_CONSTEXPR #define _GLIBCXX_SIMD_USE_CONSTEXPR_API const #else diff --git a/libstdc++-v3/include/experimental/bits/simd_x86.h b/libstdc++-v3/include/experimental/bits/simd_x86.h index 608918542c6..165738c4e2c 100644 --- a/libstdc++-v3/include/experimental/bits/simd_x86.h +++ b/libstdc++-v3/include/experimental/bits/simd_x86.h @@ -363,6 +363,53 @@ __maskload_pd(const double* __ptr, _Tp __k) // }}} +#ifdef __clang__ +template + _GLIBCXX_SIMD_INTRINSIC constexpr auto + __movm(_Kp __k) noexcept + { + static_assert(is_unsigned_v<_Kp>); + if constexpr (sizeof(_Tp) == 1 && __have_avx512bw) + { + if constexpr (_Np <= 16 && __have_avx512vl) + return __builtin_ia32_cvtmask2b128(__k); + else if constexpr (_Np <= 32 && __have_avx512vl) + return __builtin_ia32_cvtmask2b256(__k); + else + return __builtin_ia32_cvtmask2b512(__k); + } + else if constexpr (sizeof(_Tp) == 2 && __have_avx512bw) + { + if constexpr (_Np <= 8 && __have_avx512vl) + return __builtin_ia32_cvtmask2w128(__k); + else if constexpr (_Np <= 16 && __have_avx512vl) + return __builtin_ia32_cvtmask2w256(__k); + else + return __builtin_ia32_cvtmask2w512(__k); + } + else if constexpr (sizeof(_Tp) == 4 && __have_avx512dq) + { + if constexpr (_Np <= 4 && __have_avx512vl) + return __builtin_ia32_cvtmask2d128(__k); + else if constexpr (_Np <= 8 && __have_avx512vl) + return __builtin_ia32_cvtmask2d256(__k); + else + return __builtin_ia32_cvtmask2d512(__k); + } + else if constexpr (sizeof(_Tp) == 8 && __have_avx512dq) + { + if constexpr (_Np <= 2 && __have_avx512vl) + return __builtin_ia32_cvtmask2q128(__k); + else if constexpr (_Np <= 4 && __have_avx512vl) + return __builtin_ia32_cvtmask2q256(__k); + else + return __builtin_ia32_cvtmask2q512(__k); + } + else + __assert_unreachable<_Tp>(); + } +#endif // __clang__ + #ifdef _GLIBCXX_SIMD_WORKAROUND_PR85048 #include "simd_x86_conversions.h" #endif @@ -619,14 +666,13 @@ _pdep_u32( _GLIBCXX_SIMD_INTRINSIC static _TV _S_blend_avx512(const _Kp __k, const _TV __a, const _TV __b) noexcept { -#ifdef __clang__ - // FIXME: this does a boolean choice, not a blend - return __k ? __a : __b; -#else static_assert(__is_vector_type_v<_TV>); using _Tp = typename _VectorTraits<_TV>::value_type; static_assert(sizeof(_TV) >= 16); static_assert(sizeof(_Tp) <= 8); +#ifdef __clang__ + return __movm<_VectorTraits<_TV>::_S_full_size, _Tp>(__k) ? __b : __a; +#else using _IntT = conditional_t<(sizeof(_Tp) > 2), conditional_t, @@ -3483,6 +3529,10 @@ _S_masked_unary(const _SimdWrapper<_K, _Np> __k, const _SimdWrapper<_Tp, _Np> __ // optimize masked unary increment and decrement as masked sub +/-1 constexpr int __pm_one = is_same_v<_Op, __increment> ? -1 : 1; +#ifdef __clang__ + return __vector_bitcast<_Tp, _Np>(__movm<_Np, _Tp>(__k._M_data)) + ? __v._M_data - __pm_one : __v._M_data; +#else // __clang__ if constexpr (is_integral_v<_Tp>) { constexpr bool __lp64 = sizeof(long) == sizeof(long long); @@ -3526,6 +3576,7 @@ _S_masked_unary(const _SimdWrapper<_K, _Np> __k, const _SimdWrapper<_Tp, _Np> __ _GLIBCXX_SIMD_MASK_SUB(8, 16, subpd128); #undef _GLIBCXX_SIMD_MASK_SUB } +#endif // __clang__ } else return _Base::template _S_masked_unary<_Op>(__k, __v);