From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id E84DF3858C78 for ; Mon, 22 Apr 2024 16:04:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E84DF3858C78 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E84DF3858C78 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713801880; cv=none; b=ZK5QouScwbSevmnTbyyyrTltmf++6AKuQO/smvc6EB9lCyc34rt8jWdP9WNXfmuZuzSqLlUg7VHzg/e39Fu0u2ZhRxGhGdrkKdQGyA09gMQfbOfuf6Y5MnmDIF1sJs4UaqMqTxVeTAO8UJOT61a/SUzQafE13DdsU/t+1HjjFVs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713801880; c=relaxed/simple; bh=ia1mPRF78ZOKjBL7OBdQAq5gHvJ6Sd8sLrqH8Eu8Pf8=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=OmwM8WMH4Ym/vGyNiUGU3IAE9m2ph2ndi2UFsCk0i4lCrJqv5iy9I93wgJscAgFfBprvS2V446SuVGrzdslnXthuC0nXVIGe8v95nPovw0BJH96GYFZ58o3V3Mf9GBekP67/4w5jfYUiOqpdbD3KgAO9s7ZxjtB8ulqaBsh36b4= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713801870; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mG++SR4rD1OhDftv+vcilJ8vFa8CgHE8WNXzIBzFytk=; b=gaHThDhwUnUed55qgTohQJoPONA5LPfJSM8tUtyqhO4nswu9KN2igm76oxGf7TWnxdOGov 6FV23WEPscf6FWet/Lcw+2vZzdSACksPbfWGr+V36ZTuqjLBzkcym6fxq3xKn30mPK3pYx kty/mmFANjX0Oq/wk3bA2YDJBrROM44= Received: from mail-yb1-f199.google.com (mail-yb1-f199.google.com [209.85.219.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-539-LODdT0IRNIaakW9H551i4Q-1; Mon, 22 Apr 2024 12:04:29 -0400 X-MC-Unique: LODdT0IRNIaakW9H551i4Q-1 Received: by mail-yb1-f199.google.com with SMTP id 3f1490d57ef6-dcdc3db67f0so7547817276.1 for ; Mon, 22 Apr 2024 09:04:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713801868; x=1714406668; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mG++SR4rD1OhDftv+vcilJ8vFa8CgHE8WNXzIBzFytk=; b=u8hmOkPX/smmA3tDUEwQU6H8TFziJhLDR02kT3dVo79ijZNPcZr8SHFH+c5kVtDk7R kcSu7e2HVHuJWM9zDXWy3wYXhAKZmg8+bon+fY2f5AV7tvlBdoQ8ipfn+O2sk1R6CDxG 0RZerBsnaxhfpUpoa9i0qbbLBxU2vP7gRzGTOGfR4ktpOa0gGRiiJ0zeZ1ZW+5RQ4stK 4kyUPJFBeLnYftEtnR4bQicQ46KTn760YcAK0lJ/cBGSJGEEfkMgNYdBIndDjcoOKJ9+ JdGouWtg7hNpfDhSWo1MA/tZvRhIMBn+rZ+VWnv6poq9FfUXLCsFy2BI7vQkn6xVBTC0 7yoQ== X-Forwarded-Encrypted: i=1; AJvYcCWB4NouLdxOJJy4ZsAFmRskzSKIlLV7DWz7q9suJMqSCUSoNbHpgOFQTUlcP7UWfFrRYQ685vTkNyLTBjGrMkL02bNCVnI= X-Gm-Message-State: AOJu0YybKUVyXx5s14Szq94buZx1oUDUZupPA5FG2LrztlNXPMD30ZOt EOQoiAjtZaLfAw0q65BvZWPoAnE/Qica+4F1z52ORrYKOegygW1Cj8bqwwKamnRAJOeRMKLcAPR v0RXmFcOt3bHGg2Pfmr/eiAVPdQuERZNVp9ZsYe0HdxAXfL4AXB+yPs1hqRV2v34UhyxwYQJUmz zc970z8d38D9JFnwtlF5gAK2fLPXLInbVvPP0= X-Received: by 2002:a25:3625:0:b0:dc2:a46:3d29 with SMTP id d37-20020a253625000000b00dc20a463d29mr91168yba.9.1713801868440; Mon, 22 Apr 2024 09:04:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFybu0tVtz0fxDLLXXVyWXv6QL6oh/OJsAPdOXIuUfLaLaLquI49sO6jsvAGOm95glJ0Lw+a6t+gl1WGkigfps= X-Received: by 2002:a25:3625:0:b0:dc2:a46:3d29 with SMTP id d37-20020a253625000000b00dc20a463d29mr91144yba.9.1713801868125; Mon, 22 Apr 2024 09:04:28 -0700 (PDT) MIME-Version: 1.0 References: <14471703.uLZWGnKmhe@centauriprime> In-Reply-To: <14471703.uLZWGnKmhe@centauriprime> From: Jonathan Wakely Date: Mon, 22 Apr 2024 17:04:12 +0100 Message-ID: Subject: Re: [PATCH] libstdc++: Fix conversion of simd to vector builtin To: Matthias Kretz Cc: gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00,BODY_8BITS,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP,URIBL_SBL_A autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Mon, 22 Apr 2024 at 16:30, Matthias Kretz wrote: > > Tested on x86_64-linux-gnu, powerpc64le-linux-gnu, aarch64-linux-gnu, arm= - > linux-gnueabihf > > OK for trunk and backports? OK > > ----------------------------- 8< --------------------------------- > > Signed-off-by: Matthias Kretz > > libstdc++-v3/ChangeLog: > > PR libstdc++/114803 > * include/experimental/bits/simd_builtin.h > (_SimdBase2::operator __vector_type_t): There is no __builtin() > function in _SimdWrapper, instead use its conversion operator. > * testsuite/experimental/simd/pr114803_vecbuiltin_cvt.cc: New > test. > --- > .../include/experimental/bits/simd_builtin.h | 2 +- > .../simd/pr114803_vecbuiltin_cvt.cc | 105 ++++++++++++++++++ > 2 files changed, 106 insertions(+), 1 deletion(-) > create mode 100644 libstdc++-v3/testsuite/experimental/simd/ > pr114803_vecbuiltin_cvt.cc > > diff --git a/libstdc++-v3/include/experimental/bits/simd_builtin.h b/libs= tdc+ > +-v3/include/experimental/bits/simd_builtin.h > index 49c7c7e1c70..4ceeb423894 100644 > --- a/libstdc++-v3/include/experimental/bits/simd_builtin.h > +++ b/libstdc++-v3/include/experimental/bits/simd_builtin.h > @@ -841,7 +841,7 @@ struct _SimdBase2 > > _GLIBCXX_SIMD_ALWAYS_INLINE explicit > operator __vector_type_t<_Tp, _Np>() const > - { return static_cast*>(this)- > >_M_data.__builtin(); } > + { return __data(*static_cast*>(this)); } > }; > > struct _SimdBase1 > diff --git a/libstdc++-v3/testsuite/experimental/simd/ > pr114803_vecbuiltin_cvt.cc b/libstdc++-v3/testsuite/experimental/simd/ > pr114803_vecbuiltin_cvt.cc > new file mode 100644 > index 00000000000..103dd19394c > --- /dev/null > +++ b/libstdc++-v3/testsuite/experimental/simd/pr114803_vecbuiltin_cvt.cc > @@ -0,0 +1,105 @@ > +// { dg-options "-std=3Dgnu++17" } > +// { dg-do compile { target c++17 } } > + > +#include > + > +template > + void > + maybe_test() > + { > + using V =3D std::experimental::simd std::experimental::simd_abi::_VecBuiltin<16>>; > + if constexpr (std::is_destructible_v) > + { > + using V2 [[gnu::vector_size(16)]] =3D T; > + V x =3D {}; > + V2 x2 =3D static_cast(x); > + x =3D static_cast(x2); > + for (unsigned i =3D 0; i < V::size(); ++i) > + { > + if (x2[i] !=3D 0) > + __builtin_abort(); > + } > +#ifdef __SSE__ > + if constexpr (std::is_same_v) > + x =3D static_cast(static_cast<__m128>(x)); > + else if constexpr (std::is_same_v) > + x =3D static_cast(static_cast<__m128d>(x)); > + else if constexpr (std::is_integral_v) > + x =3D static_cast(static_cast<__m128i>(x)); > +#elif __ALTIVEC__ > + if constexpr (std::is_same_v) > + x =3D static_cast(static_cast<__vector float>(x)); > +#ifdef __VSX__ > + else if constexpr (std::is_same_v) > + x =3D static_cast(static_cast<__vector double>(x)); > +#endif > + else if constexpr (std::is_integral_v && sizeof(T) =3D=3D > sizeof(signed char) > + && std::is_signed_v) > + x =3D static_cast(static_cast<__vector signed char>(x)); > + else if constexpr (std::is_integral_v && sizeof(T) =3D=3D > sizeof(signed char)) > + x =3D static_cast(static_cast<__vector unsigned char>(x)); > + else if constexpr (std::is_integral_v && sizeof(T) =3D=3D > sizeof(short) > + && std::is_signed_v) > + x =3D static_cast(static_cast<__vector signed short>(x)); > + else if constexpr (std::is_integral_v && sizeof(T) =3D=3D > sizeof(short)) > + x =3D static_cast(static_cast<__vector unsigned short>(x)); > + else if constexpr (std::is_integral_v && sizeof(T) =3D=3D size= of(int) > + && std::is_signed_v) > + x =3D static_cast(static_cast<__vector signed int>(x)); > + else if constexpr (std::is_integral_v && sizeof(T) =3D=3D size= of(int)) > + x =3D static_cast(static_cast<__vector unsigned int>(x)); > +#ifdef __VSX__ > + else if constexpr (std::is_integral_v && sizeof(T) =3D=3D size= of(long > long) > + && std::is_signed_v) > + x =3D static_cast(static_cast<__vector signed long long>(x))= ; > + else if constexpr (std::is_integral_v && sizeof(T) =3D=3D size= of(long > long)) > + x =3D static_cast(static_cast<__vector unsigned long long>(x= )); > +#endif > +#elif __ARM_NEON > + if constexpr (std::is_same_v) > + x =3D static_cast(static_cast(x)); > +#ifdef __aarch64__ > + else if constexpr (std::is_same_v) > + x =3D static_cast(static_cast(x)); > +#endif > + else if constexpr (std::is_integral_v && sizeof(T) =3D=3D 1 && > std::is_signed_v) > + x =3D static_cast(static_cast(x)); > + else if constexpr (std::is_integral_v && sizeof(T) =3D=3D 1) > + x =3D static_cast(static_cast(x)); > + else if constexpr (std::is_integral_v && sizeof(T) =3D=3D 2 && > std::is_signed_v) > + x =3D static_cast(static_cast(x)); > + else if constexpr (std::is_integral_v && sizeof(T) =3D=3D 2) > + x =3D static_cast(static_cast(x)); > + else if constexpr (std::is_integral_v && sizeof(T) =3D=3D 4 && > std::is_signed_v) > + x =3D static_cast(static_cast(x)); > + else if constexpr (std::is_integral_v && sizeof(T) =3D=3D 4) > + x =3D static_cast(static_cast(x)); > + else if constexpr (std::is_integral_v && sizeof(T) =3D=3D 8 && > std::is_signed_v) > + x =3D static_cast(static_cast(x)); > + else if constexpr (std::is_integral_v && sizeof(T) =3D=3D 8) > + x =3D static_cast(static_cast(x)); > +#endif > + } > + } > + > +int main() > +{ > + maybe_test(); > + maybe_test(); > + maybe_test(); > + maybe_test(); > + > + maybe_test(); > + maybe_test(); > + maybe_test(); > + maybe_test(); > + maybe_test(); > + maybe_test(); > + maybe_test(); > + maybe_test(); > + maybe_test(); > + maybe_test(); > + maybe_test(); > + maybe_test(); > + maybe_test(); > +} > -- > =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80= =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94= =80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80= =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94= =80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80= =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80 > Dr. Matthias Kretz https://mattkretz.github.io > GSI Helmholtz Centre for Heavy Ion Research https://gsi.de > std=E2=82=93::simd > =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80= =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94= =80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80= =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94= =80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80= =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80 >