public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/109261] New: std::experimental::simd is not usable in several constant expressions
@ 2023-03-23 10:02 mkretz at gcc dot gnu.org
  2023-03-23 10:02 ` [Bug libstdc++/109261] " mkretz at gcc dot gnu.org
                   ` (20 more replies)
  0 siblings, 21 replies; 22+ messages in thread
From: mkretz at gcc dot gnu.org @ 2023-03-23 10:02 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109261

            Bug ID: 109261
           Summary: std::experimental::simd is not usable in several
                    constant expressions
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: mkretz at gcc dot gnu.org
          Reporter: mkretz at gcc dot gnu.org
  Target Milestone: ---

std::experimental::simd wants to work in constant expressions with
-std=gnu++17. But it fails for many valid cases.

Testcase (https://godbolt.org/z/sjrfMM89h):

#include <experimental/simd>
#include <array>

using V = std::experimental::simd<int>;
using V12 = std::experimental::fixed_size_simd<int, 12>;

constexpr std::array<int, V12::size()> data = {};
constexpr auto a = V12(data.data(), std::experimental::element_aligned);

constexpr auto b = []() constexpr {
    V12 x = 1;
    where(x > 0, x) = 0;
    return x;
}();

constexpr auto c = V()[0];

constexpr auto d = !V() && !!V();

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug libstdc++/109261] std::experimental::simd is not usable in several constant expressions
  2023-03-23 10:02 [Bug libstdc++/109261] New: std::experimental::simd is not usable in several constant expressions mkretz at gcc dot gnu.org
@ 2023-03-23 10:02 ` mkretz at gcc dot gnu.org
  2023-04-26  6:58 ` rguenth at gcc dot gnu.org
                   ` (19 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: mkretz at gcc dot gnu.org @ 2023-03-23 10:02 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109261

Matthias Kretz (Vir) <mkretz at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2023-03-23
             Status|UNCONFIRMED                 |ASSIGNED
     Ever confirmed|0                           |1
   Target Milestone|---                         |13.0

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug libstdc++/109261] std::experimental::simd is not usable in several constant expressions
  2023-03-23 10:02 [Bug libstdc++/109261] New: std::experimental::simd is not usable in several constant expressions mkretz at gcc dot gnu.org
  2023-03-23 10:02 ` [Bug libstdc++/109261] " mkretz at gcc dot gnu.org
@ 2023-04-26  6:58 ` rguenth at gcc dot gnu.org
  2023-05-23  7:27 ` cvs-commit at gcc dot gnu.org
                   ` (18 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-04-26  6:58 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109261

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|13.0                        |13.2

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 13.1 is being released, retargeting bugs to GCC 13.2.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug libstdc++/109261] std::experimental::simd is not usable in several constant expressions
  2023-03-23 10:02 [Bug libstdc++/109261] New: std::experimental::simd is not usable in several constant expressions mkretz at gcc dot gnu.org
  2023-03-23 10:02 ` [Bug libstdc++/109261] " mkretz at gcc dot gnu.org
  2023-04-26  6:58 ` rguenth at gcc dot gnu.org
@ 2023-05-23  7:27 ` cvs-commit at gcc dot gnu.org
  2023-05-23 10:03 ` cvs-commit at gcc dot gnu.org
                   ` (17 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-05-23  7:27 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109261

--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Matthias Kretz <mkretz@gcc.gnu.org>:

https://gcc.gnu.org/g:da579188807ede4ee9466d0b5bf51559c96a0b51

commit r14-1084-gda579188807ede4ee9466d0b5bf51559c96a0b51
Author: Matthias Kretz <m.kretz@gsi.de>
Date:   Thu Mar 23 09:32:58 2023 +0100

    libstdc++: Add missing constexpr to simd

    The constexpr API is only available with -std=gnu++XX (and proposed for
    C++26). The proposal is to have the complete simd API usable in constant
    expressions.

    This patch resolves several issues with using simd in constant
    expressions.

    Issues why constant_evaluated branches are necessary:
    * subscripting vector builtins is not allowed in constant expressions
    * if the implementation needs/uses memcpy
    * if the implementation would otherwise call SIMD intrinsics/builtins

    Signed-off-by: Matthias Kretz <m.kretz@gsi.de>

    libstdc++-v3/ChangeLog:

            PR libstdc++/109261
            * include/experimental/bits/simd.h (_SimdWrapper::_M_set):
            Avoid vector builtin subscripting in constant expressions.
            (resizing_simd_cast): Avoid memcpy if constant_evaluated.
            (const_where_expression, where_expression, where)
            (__extract_part, simd_mask, _SimdIntOperators, simd): Add either
            _GLIBCXX_SIMD_CONSTEXPR (on public APIs), or constexpr (on
            internal APIs).
            * include/experimental/bits/simd_builtin.h (__vector_permute)
            (__vector_shuffle, __extract_part, _GnuTraits::_SimdCastType1)
            (_GnuTraits::_SimdCastType2, _SimdImplBuiltin)
            (_MaskImplBuiltin::_S_store): Add constexpr.
            (_CommonImplBuiltin::_S_store_bool_array)
            (_SimdImplBuiltin::_S_load, _SimdImplBuiltin::_S_store)
            (_SimdImplBuiltin::_S_reduce, _MaskImplBuiltin::_S_load): Add
            constant_evaluated case.
            * include/experimental/bits/simd_fixed_size.h
            (_S_masked_load): Reword comment.
            (__tuple_element_meta, __make_meta, _SimdTuple::_M_apply_r)
            (_SimdTuple::_M_subscript_read, _SimdTuple::_M_subscript_write)
            (__make_simd_tuple, __optimize_simd_tuple, __extract_part)
            (__autocvt_to_simd, _Fixed::__traits::_SimdBase)
            (_Fixed::__traits::_SimdCastType, _SimdImplFixedSize): Add
            constexpr.
            (_SimdTuple::operator[], _M_set): Add constexpr and add
            constant_evaluated case.
            (_MaskImplFixedSize::_S_load): Add constant_evaluated case.
            * include/experimental/bits/simd_scalar.h: Add constexpr.

            * include/experimental/bits/simd_x86.h (_CommonImplX86): Add
            constexpr and add constant_evaluated case.
            (_SimdImplX86::_S_equal_to, _S_not_equal_to, _S_less)
            (_S_less_equal): Value-initialize to satisfy constexpr
            evaluation.
            (_MaskImplX86::_S_load): Add constant_evaluated case.
            (_MaskImplX86::_S_store): Add constexpr and constant_evaluated
            case. Value-initialize local variables.
            (_MaskImplX86::_S_logical_and, _S_logical_or, _S_bit_not)
            (_S_bit_and, _S_bit_or, _S_bit_xor): Add constant_evaluated
            case.
            * testsuite/experimental/simd/pr109261_constexpr_simd.cc: New
            test.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug libstdc++/109261] std::experimental::simd is not usable in several constant expressions
  2023-03-23 10:02 [Bug libstdc++/109261] New: std::experimental::simd is not usable in several constant expressions mkretz at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2023-05-23  7:27 ` cvs-commit at gcc dot gnu.org
@ 2023-05-23 10:03 ` cvs-commit at gcc dot gnu.org
  2023-05-23 15:14 ` clyon at gcc dot gnu.org
                   ` (16 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-05-23 10:03 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109261

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Matthias Kretz
<mkretz@gcc.gnu.org>:

https://gcc.gnu.org/g:3acbaf1b25321508d780a8220b772fc9cd871b13

commit r12-9647-g3acbaf1b25321508d780a8220b772fc9cd871b13
Author: Matthias Kretz <m.kretz@gsi.de>
Date:   Thu Mar 23 09:32:58 2023 +0100

    libstdc++: Add missing constexpr to simd

    The constexpr API is only available with -std=gnu++XX (and proposed for
    C++26). The proposal is to have the complete simd API usable in constant
    expressions.

    This patch resolves several issues with using simd in constant
    expressions.

    Issues why constant_evaluated branches are necessary:
    * subscripting vector builtins is not allowed in constant expressions
    * if the implementation needs/uses memcpy
    * if the implementation would otherwise call SIMD intrinsics/builtins

    Signed-off-by: Matthias Kretz <m.kretz@gsi.de>

    libstdc++-v3/ChangeLog:

            PR libstdc++/109261
            * include/experimental/bits/simd.h (_SimdWrapper::_M_set):
            Avoid vector builtin subscripting in constant expressions.
            (resizing_simd_cast): Avoid memcpy if constant_evaluated.
            (const_where_expression, where_expression, where)
            (__extract_part, simd_mask, _SimdIntOperators, simd): Add either
            _GLIBCXX_SIMD_CONSTEXPR (on public APIs), or constexpr (on
            internal APIs).
            * include/experimental/bits/simd_builtin.h (__vector_permute)
            (__vector_shuffle, __extract_part, _GnuTraits::_SimdCastType1)
            (_GnuTraits::_SimdCastType2, _SimdImplBuiltin)
            (_MaskImplBuiltin::_S_store): Add constexpr.
            (_CommonImplBuiltin::_S_store_bool_array)
            (_SimdImplBuiltin::_S_load, _SimdImplBuiltin::_S_store)
            (_SimdImplBuiltin::_S_reduce, _MaskImplBuiltin::_S_load): Add
            constant_evaluated case.
            * include/experimental/bits/simd_fixed_size.h
            (_S_masked_load): Reword comment.
            (__tuple_element_meta, __make_meta, _SimdTuple::_M_apply_r)
            (_SimdTuple::_M_subscript_read, _SimdTuple::_M_subscript_write)
            (__make_simd_tuple, __optimize_simd_tuple, __extract_part)
            (__autocvt_to_simd, _Fixed::__traits::_SimdBase)
            (_Fixed::__traits::_SimdCastType, _SimdImplFixedSize): Add
            constexpr.
            (_SimdTuple::operator[], _M_set): Add constexpr and add
            constant_evaluated case.
            (_MaskImplFixedSize::_S_load): Add constant_evaluated case.
            * include/experimental/bits/simd_scalar.h: Add constexpr.

            * include/experimental/bits/simd_x86.h (_CommonImplX86): Add
            constexpr and add constant_evaluated case.
            (_SimdImplX86::_S_equal_to, _S_not_equal_to, _S_less)
            (_S_less_equal): Value-initialize to satisfy constexpr
            evaluation.
            (_MaskImplX86::_S_load): Add constant_evaluated case.
            (_MaskImplX86::_S_store): Add constexpr and constant_evaluated
            case. Value-initialize local variables.
            (_MaskImplX86::_S_logical_and, _S_logical_or, _S_bit_not)
            (_S_bit_and, _S_bit_or, _S_bit_xor): Add constant_evaluated
            case.
            * testsuite/experimental/simd/pr109261_constexpr_simd.cc: New
            test.

    (cherry picked from commit da579188807ede4ee9466d0b5bf51559c96a0b51)

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug libstdc++/109261] std::experimental::simd is not usable in several constant expressions
  2023-03-23 10:02 [Bug libstdc++/109261] New: std::experimental::simd is not usable in several constant expressions mkretz at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2023-05-23 10:03 ` cvs-commit at gcc dot gnu.org
@ 2023-05-23 15:14 ` clyon at gcc dot gnu.org
  2023-05-23 15:37 ` mkretz at gcc dot gnu.org
                   ` (15 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: clyon at gcc dot gnu.org @ 2023-05-23 15:14 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109261

Christophe Lyon <clyon at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clyon at gcc dot gnu.org

--- Comment #4 from Christophe Lyon <clyon at gcc dot gnu.org> ---
The new testcase fails on arm and aarch64.

For instance on arm, the log shows:

/libstdc++-v3/testsuite/experimental/simd/pr109261_constexpr_simd.cc:45: error:
non-constant condition for static assertion
/libstdc++-v3/testsuite/experimental/simd/pr109261_constexpr_simd.cc:46: error:
non-constant condition for static assertion
/libstdc++-v3/testsuite/experimental/simd/pr109261_constexpr_simd.cc:56: error:
non-constant condition for static assertion
/libstdc++-v3/testsuite/experimental/simd/pr109261_constexpr_simd.cc:56: error:
'constexpr _Tp std::experimental::parallelism_v2::hmin(const simd<_Tp, _Ap>&)
[with _Tp = char; _Abi = simd_abi::_VecBuiltin<16>]' called in a constant
expression
/libstdc++-v3/testsuite/experimental/simd/pr109261_constexpr_simd.cc:57: error:
non-constant condition for static assertion
/libstdc++-v3/testsuite/experimental/simd/pr109261_constexpr_simd.cc:57: error:
'constexpr _Tp std::experimental::parallelism_v2::hmax(const simd<_Tp, _Ap>&)
[with _Tp = char; _Abi = simd_abi::_VecBuiltin<16>]' called in a constant
expression

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug libstdc++/109261] std::experimental::simd is not usable in several constant expressions
  2023-03-23 10:02 [Bug libstdc++/109261] New: std::experimental::simd is not usable in several constant expressions mkretz at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2023-05-23 15:14 ` clyon at gcc dot gnu.org
@ 2023-05-23 15:37 ` mkretz at gcc dot gnu.org
  2023-05-23 16:19 ` clyon at gcc dot gnu.org
                   ` (14 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: mkretz at gcc dot gnu.org @ 2023-05-23 15:37 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109261

--- Comment #5 from Matthias Kretz (Vir) <mkretz at gcc dot gnu.org> ---
Th(In reply to Christophe Lyon from comment #4)
> The new testcase fails on arm and aarch64.

trunk or the backport? I tested trunk on gcc185. Will check.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug libstdc++/109261] std::experimental::simd is not usable in several constant expressions
  2023-03-23 10:02 [Bug libstdc++/109261] New: std::experimental::simd is not usable in several constant expressions mkretz at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2023-05-23 15:37 ` mkretz at gcc dot gnu.org
@ 2023-05-23 16:19 ` clyon at gcc dot gnu.org
  2023-05-23 22:08 ` mkretz at gcc dot gnu.org
                   ` (13 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: clyon at gcc dot gnu.org @ 2023-05-23 16:19 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109261

--- Comment #6 from Christophe Lyon <clyon at gcc dot gnu.org> ---

> trunk or the backport? I tested trunk on gcc185. Will check.

That's on trunk (didn't check on the branch)

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug libstdc++/109261] std::experimental::simd is not usable in several constant expressions
  2023-03-23 10:02 [Bug libstdc++/109261] New: std::experimental::simd is not usable in several constant expressions mkretz at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2023-05-23 16:19 ` clyon at gcc dot gnu.org
@ 2023-05-23 22:08 ` mkretz at gcc dot gnu.org
  2023-05-24  8:28 ` clyon at gcc dot gnu.org
                   ` (12 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: mkretz at gcc dot gnu.org @ 2023-05-23 22:08 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109261

--- Comment #7 from Matthias Kretz (Vir) <mkretz at gcc dot gnu.org> ---
Created attachment 55146
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55146&action=edit
patch that resolves it for me

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug libstdc++/109261] std::experimental::simd is not usable in several constant expressions
  2023-03-23 10:02 [Bug libstdc++/109261] New: std::experimental::simd is not usable in several constant expressions mkretz at gcc dot gnu.org
                   ` (7 preceding siblings ...)
  2023-05-23 22:08 ` mkretz at gcc dot gnu.org
@ 2023-05-24  8:28 ` clyon at gcc dot gnu.org
  2023-05-24 11:06 ` cvs-commit at gcc dot gnu.org
                   ` (11 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: clyon at gcc dot gnu.org @ 2023-05-24  8:28 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109261

--- Comment #8 from Christophe Lyon <clyon at gcc dot gnu.org> ---
I guess gcc185 is an aarch64 machine? (as opposed to arm)

I confirm your patch fixes the problem on aarch64 (the testcase now passes),
but it still fails on arm, with:
/arm-linux-gnueabihf/libstdc++-v3/include/experimental/bits/simd.h:2412: error:
static assertion failed: should use explicit specialization above
/arm-linux-gnueabihf/libstdc++-v3/include/experimental/bits/simd.h:2415: error:
invalid use of incomplete type 'struct
std::experimental::parallelism_v2::__intrinsic_type<double, 16, void>'

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug libstdc++/109261] std::experimental::simd is not usable in several constant expressions
  2023-03-23 10:02 [Bug libstdc++/109261] New: std::experimental::simd is not usable in several constant expressions mkretz at gcc dot gnu.org
                   ` (8 preceding siblings ...)
  2023-05-24  8:28 ` clyon at gcc dot gnu.org
@ 2023-05-24 11:06 ` cvs-commit at gcc dot gnu.org
  2023-05-24 11:06 ` cvs-commit at gcc dot gnu.org
                   ` (10 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-05-24 11:06 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109261

--- Comment #9 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Matthias Kretz <mkretz@gcc.gnu.org>:

https://gcc.gnu.org/g:b0a483b0a011f9cbc8b25053eae809c77dae2a12

commit r14-1159-gb0a483b0a011f9cbc8b25053eae809c77dae2a12
Author: Matthias Kretz <m.kretz@gsi.de>
Date:   Tue May 23 23:48:49 2023 +0200

    libstdc++: Add missing constexpr to simd_neon

    Signed-off-by: Matthias Kretz <m.kretz@gsi.de>

    libstdc++-v3/ChangeLog:

            PR libstdc++/109261
            * include/experimental/bits/simd_neon.h (_S_reduce): Add
            constexpr and make NEON implementation conditional on
            not __builtin_is_constant_evaluated.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug libstdc++/109261] std::experimental::simd is not usable in several constant expressions
  2023-03-23 10:02 [Bug libstdc++/109261] New: std::experimental::simd is not usable in several constant expressions mkretz at gcc dot gnu.org
                   ` (9 preceding siblings ...)
  2023-05-24 11:06 ` cvs-commit at gcc dot gnu.org
@ 2023-05-24 11:06 ` cvs-commit at gcc dot gnu.org
  2023-05-24 12:31 ` clyon at gcc dot gnu.org
                   ` (9 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-05-24 11:06 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109261

--- Comment #10 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Matthias Kretz <mkretz@gcc.gnu.org>:

https://gcc.gnu.org/g:aa8b363171a95b8f867a74f29c75f9577e9087e1

commit r14-1160-gaa8b363171a95b8f867a74f29c75f9577e9087e1
Author: Matthias Kretz <m.kretz@gsi.de>
Date:   Wed May 24 12:50:46 2023 +0200

    libstdc++: Fix SFINAE for __is_intrinsic_type on ARM

    On ARM NEON doesn't support double, so __is_intrinsic_type_v<double,
    whatever> should say false (instead of being ill-formed).

    Signed-off-by: Matthias Kretz <m.kretz@gsi.de>

    libstdc++-v3/ChangeLog:

            PR libstdc++/109261
            * include/experimental/bits/simd.h (__intrinsic_type):
            Specialize __intrinsic_type<double, 8> and
            __intrinsic_type<double, 16> in any case, but provide the member
            type only with __aarch64__.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug libstdc++/109261] std::experimental::simd is not usable in several constant expressions
  2023-03-23 10:02 [Bug libstdc++/109261] New: std::experimental::simd is not usable in several constant expressions mkretz at gcc dot gnu.org
                   ` (10 preceding siblings ...)
  2023-05-24 11:06 ` cvs-commit at gcc dot gnu.org
@ 2023-05-24 12:31 ` clyon at gcc dot gnu.org
  2023-05-24 19:41 ` cvs-commit at gcc dot gnu.org
                   ` (8 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: clyon at gcc dot gnu.org @ 2023-05-24 12:31 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109261

--- Comment #11 from Christophe Lyon <clyon at gcc dot gnu.org> ---
Thanks, trunk is now OK on both arm and aarch64.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug libstdc++/109261] std::experimental::simd is not usable in several constant expressions
  2023-03-23 10:02 [Bug libstdc++/109261] New: std::experimental::simd is not usable in several constant expressions mkretz at gcc dot gnu.org
                   ` (11 preceding siblings ...)
  2023-05-24 12:31 ` clyon at gcc dot gnu.org
@ 2023-05-24 19:41 ` cvs-commit at gcc dot gnu.org
  2023-05-24 19:41 ` cvs-commit at gcc dot gnu.org
                   ` (7 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-05-24 19:41 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109261

--- Comment #12 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Matthias Kretz
<mkretz@gcc.gnu.org>:

https://gcc.gnu.org/g:8be71168f7bbafa04f592a7524432351ffea71ba

commit r12-9650-g8be71168f7bbafa04f592a7524432351ffea71ba
Author: Matthias Kretz <m.kretz@gsi.de>
Date:   Tue May 23 23:48:49 2023 +0200

    libstdc++: Add missing constexpr to simd_neon

    Signed-off-by: Matthias Kretz <m.kretz@gsi.de>

    libstdc++-v3/ChangeLog:

            PR libstdc++/109261
            * include/experimental/bits/simd_neon.h (_S_reduce): Add
            constexpr and make NEON implementation conditional on
            not __builtin_is_constant_evaluated.

    (cherry picked from commit b0a483b0a011f9cbc8b25053eae809c77dae2a12)

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug libstdc++/109261] std::experimental::simd is not usable in several constant expressions
  2023-03-23 10:02 [Bug libstdc++/109261] New: std::experimental::simd is not usable in several constant expressions mkretz at gcc dot gnu.org
                   ` (12 preceding siblings ...)
  2023-05-24 19:41 ` cvs-commit at gcc dot gnu.org
@ 2023-05-24 19:41 ` cvs-commit at gcc dot gnu.org
  2023-05-25  7:03 ` cvs-commit at gcc dot gnu.org
                   ` (6 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-05-24 19:41 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109261

--- Comment #13 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Matthias Kretz
<mkretz@gcc.gnu.org>:

https://gcc.gnu.org/g:2b502c3119c91fe3ba2313f0842a3bedd395bc91

commit r12-9651-g2b502c3119c91fe3ba2313f0842a3bedd395bc91
Author: Matthias Kretz <m.kretz@gsi.de>
Date:   Wed May 24 12:50:46 2023 +0200

    libstdc++: Fix SFINAE for __is_intrinsic_type on ARM

    On ARM NEON doesn't support double, so __is_intrinsic_type_v<double,
    whatever> should say false (instead of being ill-formed).

    Signed-off-by: Matthias Kretz <m.kretz@gsi.de>

    libstdc++-v3/ChangeLog:

            PR libstdc++/109261
            * include/experimental/bits/simd.h (__intrinsic_type):
            Specialize __intrinsic_type<double, 8> and
            __intrinsic_type<double, 16> in any case, but provide the member
            type only with __aarch64__.

    (cherry picked from commit aa8b363171a95b8f867a74f29c75f9577e9087e1)

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug libstdc++/109261] std::experimental::simd is not usable in several constant expressions
  2023-03-23 10:02 [Bug libstdc++/109261] New: std::experimental::simd is not usable in several constant expressions mkretz at gcc dot gnu.org
                   ` (13 preceding siblings ...)
  2023-05-24 19:41 ` cvs-commit at gcc dot gnu.org
@ 2023-05-25  7:03 ` cvs-commit at gcc dot gnu.org
  2023-05-25  7:03 ` cvs-commit at gcc dot gnu.org
                   ` (5 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-05-25  7:03 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109261

--- Comment #14 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-13 branch has been updated by Matthias Kretz
<mkretz@gcc.gnu.org>:

https://gcc.gnu.org/g:0f9f9c0f79a1a2a1cd6abd86b84dedbd0d263a42

commit r13-7372-g0f9f9c0f79a1a2a1cd6abd86b84dedbd0d263a42
Author: Matthias Kretz <m.kretz@gsi.de>
Date:   Wed May 24 12:50:46 2023 +0200

    libstdc++: Fix SFINAE for __is_intrinsic_type on ARM

    On ARM NEON doesn't support double, so __is_intrinsic_type_v<double,
    whatever> should say false (instead of being ill-formed).

    Signed-off-by: Matthias Kretz <m.kretz@gsi.de>

    libstdc++-v3/ChangeLog:

            PR libstdc++/109261
            * include/experimental/bits/simd.h (__intrinsic_type):
            Specialize __intrinsic_type<double, 8> and
            __intrinsic_type<double, 16> in any case, but provide the member
            type only with __aarch64__.

    (cherry picked from commit aa8b363171a95b8f867a74f29c75f9577e9087e1)

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug libstdc++/109261] std::experimental::simd is not usable in several constant expressions
  2023-03-23 10:02 [Bug libstdc++/109261] New: std::experimental::simd is not usable in several constant expressions mkretz at gcc dot gnu.org
                   ` (14 preceding siblings ...)
  2023-05-25  7:03 ` cvs-commit at gcc dot gnu.org
@ 2023-05-25  7:03 ` cvs-commit at gcc dot gnu.org
  2023-05-25  7:04 ` cvs-commit at gcc dot gnu.org
                   ` (4 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-05-25  7:03 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109261

--- Comment #15 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-13 branch has been updated by Matthias Kretz
<mkretz@gcc.gnu.org>:

https://gcc.gnu.org/g:a51ed14784df49eeceea1813b1d458516031bf52

commit r13-7373-ga51ed14784df49eeceea1813b1d458516031bf52
Author: Matthias Kretz <m.kretz@gsi.de>
Date:   Tue May 23 23:48:49 2023 +0200

    libstdc++: Add missing constexpr to simd_neon

    Signed-off-by: Matthias Kretz <m.kretz@gsi.de>

    libstdc++-v3/ChangeLog:

            PR libstdc++/109261
            * include/experimental/bits/simd_neon.h (_S_reduce): Add
            constexpr and make NEON implementation conditional on
            not __builtin_is_constant_evaluated.

    (cherry picked from commit b0a483b0a011f9cbc8b25053eae809c77dae2a12)

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug libstdc++/109261] std::experimental::simd is not usable in several constant expressions
  2023-03-23 10:02 [Bug libstdc++/109261] New: std::experimental::simd is not usable in several constant expressions mkretz at gcc dot gnu.org
                   ` (15 preceding siblings ...)
  2023-05-25  7:03 ` cvs-commit at gcc dot gnu.org
@ 2023-05-25  7:04 ` cvs-commit at gcc dot gnu.org
  2023-05-25  7:05 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-05-25  7:04 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109261

--- Comment #16 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-13 branch has been updated by Matthias Kretz
<mkretz@gcc.gnu.org>:

https://gcc.gnu.org/g:dad9abd7daa1d977e79af7ac76c17c91464aca08

commit r13-7375-gdad9abd7daa1d977e79af7ac76c17c91464aca08
Author: Matthias Kretz <m.kretz@gsi.de>
Date:   Thu Mar 23 09:32:58 2023 +0100

    libstdc++: Add missing constexpr to simd

    The constexpr API is only available with -std=gnu++XX (and proposed for
    C++26). The proposal is to have the complete simd API usable in constant
    expressions.

    This patch resolves several issues with using simd in constant
    expressions.

    Issues why constant_evaluated branches are necessary:
    * subscripting vector builtins is not allowed in constant expressions
    * if the implementation needs/uses memcpy
    * if the implementation would otherwise call SIMD intrinsics/builtins

    Signed-off-by: Matthias Kretz <m.kretz@gsi.de>

    libstdc++-v3/ChangeLog:

            PR libstdc++/109261
            * include/experimental/bits/simd.h (_SimdWrapper::_M_set):
            Avoid vector builtin subscripting in constant expressions.
            (resizing_simd_cast): Avoid memcpy if constant_evaluated.
            (const_where_expression, where_expression, where)
            (__extract_part, simd_mask, _SimdIntOperators, simd): Add either
            _GLIBCXX_SIMD_CONSTEXPR (on public APIs), or constexpr (on
            internal APIs).
            * include/experimental/bits/simd_builtin.h (__vector_permute)
            (__vector_shuffle, __extract_part, _GnuTraits::_SimdCastType1)
            (_GnuTraits::_SimdCastType2, _SimdImplBuiltin)
            (_MaskImplBuiltin::_S_store): Add constexpr.
            (_CommonImplBuiltin::_S_store_bool_array)
            (_SimdImplBuiltin::_S_load, _SimdImplBuiltin::_S_store)
            (_SimdImplBuiltin::_S_reduce, _MaskImplBuiltin::_S_load): Add
            constant_evaluated case.
            * include/experimental/bits/simd_fixed_size.h
            (_S_masked_load): Reword comment.
            (__tuple_element_meta, __make_meta, _SimdTuple::_M_apply_r)
            (_SimdTuple::_M_subscript_read, _SimdTuple::_M_subscript_write)
            (__make_simd_tuple, __optimize_simd_tuple, __extract_part)
            (__autocvt_to_simd, _Fixed::__traits::_SimdBase)
            (_Fixed::__traits::_SimdCastType, _SimdImplFixedSize): Add
            constexpr.
            (_SimdTuple::operator[], _M_set): Add constexpr and add
            constant_evaluated case.
            (_MaskImplFixedSize::_S_load): Add constant_evaluated case.
            * include/experimental/bits/simd_scalar.h: Add constexpr.

            * include/experimental/bits/simd_x86.h (_CommonImplX86): Add
            constexpr and add constant_evaluated case.
            (_SimdImplX86::_S_equal_to, _S_not_equal_to, _S_less)
            (_S_less_equal): Value-initialize to satisfy constexpr
            evaluation.
            (_MaskImplX86::_S_load): Add constant_evaluated case.
            (_MaskImplX86::_S_store): Add constexpr and constant_evaluated
            case. Value-initialize local variables.
            (_MaskImplX86::_S_logical_and, _S_logical_or, _S_bit_not)
            (_S_bit_and, _S_bit_or, _S_bit_xor): Add constant_evaluated
            case.
            * testsuite/experimental/simd/pr109261_constexpr_simd.cc: New
            test.

    (cherry picked from commit da579188807ede4ee9466d0b5bf51559c96a0b51)

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug libstdc++/109261] std::experimental::simd is not usable in several constant expressions
  2023-03-23 10:02 [Bug libstdc++/109261] New: std::experimental::simd is not usable in several constant expressions mkretz at gcc dot gnu.org
                   ` (16 preceding siblings ...)
  2023-05-25  7:04 ` cvs-commit at gcc dot gnu.org
@ 2023-05-25  7:05 ` cvs-commit at gcc dot gnu.org
  2023-05-25  7:05 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-05-25  7:05 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109261

--- Comment #17 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Matthias Kretz
<mkretz@gcc.gnu.org>:

https://gcc.gnu.org/g:f2299a4b2769941cd995e3a0530ff243153fcea2

commit r11-10821-gf2299a4b2769941cd995e3a0530ff243153fcea2
Author: Matthias Kretz <m.kretz@gsi.de>
Date:   Tue May 23 23:48:49 2023 +0200

    libstdc++: Add missing constexpr to simd_neon

    Signed-off-by: Matthias Kretz <m.kretz@gsi.de>

    libstdc++-v3/ChangeLog:

            PR libstdc++/109261
            * include/experimental/bits/simd_neon.h (_S_reduce): Add
            constexpr and make NEON implementation conditional on
            not __builtin_is_constant_evaluated.

    (cherry picked from commit b0a483b0a011f9cbc8b25053eae809c77dae2a12)

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug libstdc++/109261] std::experimental::simd is not usable in several constant expressions
  2023-03-23 10:02 [Bug libstdc++/109261] New: std::experimental::simd is not usable in several constant expressions mkretz at gcc dot gnu.org
                   ` (17 preceding siblings ...)
  2023-05-25  7:05 ` cvs-commit at gcc dot gnu.org
@ 2023-05-25  7:05 ` cvs-commit at gcc dot gnu.org
  2023-05-25  7:05 ` cvs-commit at gcc dot gnu.org
  2023-05-25  7:07 ` mkretz at gcc dot gnu.org
  20 siblings, 0 replies; 22+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-05-25  7:05 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109261

--- Comment #18 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Matthias Kretz
<mkretz@gcc.gnu.org>:

https://gcc.gnu.org/g:ad27280442d7979cf9da03d59268919fecfd12f4

commit r11-10822-gad27280442d7979cf9da03d59268919fecfd12f4
Author: Matthias Kretz <m.kretz@gsi.de>
Date:   Wed May 24 12:50:46 2023 +0200

    libstdc++: Fix SFINAE for __is_intrinsic_type on ARM

    On ARM NEON doesn't support double, so __is_intrinsic_type_v<double,
    whatever> should say false (instead of being ill-formed).

    Signed-off-by: Matthias Kretz <m.kretz@gsi.de>

    libstdc++-v3/ChangeLog:

            PR libstdc++/109261
            * include/experimental/bits/simd.h (__intrinsic_type):
            Specialize __intrinsic_type<double, 8> and
            __intrinsic_type<double, 16> in any case, but provide the member
            type only with __aarch64__.

    (cherry picked from commit aa8b363171a95b8f867a74f29c75f9577e9087e1)

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug libstdc++/109261] std::experimental::simd is not usable in several constant expressions
  2023-03-23 10:02 [Bug libstdc++/109261] New: std::experimental::simd is not usable in several constant expressions mkretz at gcc dot gnu.org
                   ` (18 preceding siblings ...)
  2023-05-25  7:05 ` cvs-commit at gcc dot gnu.org
@ 2023-05-25  7:05 ` cvs-commit at gcc dot gnu.org
  2023-05-25  7:07 ` mkretz at gcc dot gnu.org
  20 siblings, 0 replies; 22+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-05-25  7:05 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109261

--- Comment #19 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Matthias Kretz
<mkretz@gcc.gnu.org>:

https://gcc.gnu.org/g:7e289c12ce0da962ef258c992f7c52710198e3a6

commit r11-10824-g7e289c12ce0da962ef258c992f7c52710198e3a6
Author: Matthias Kretz <m.kretz@gsi.de>
Date:   Thu Mar 23 09:32:58 2023 +0100

    libstdc++: Add missing constexpr to simd

    The constexpr API is only available with -std=gnu++XX (and proposed for
    C++26). The proposal is to have the complete simd API usable in constant
    expressions.

    This patch resolves several issues with using simd in constant
    expressions.

    Issues why constant_evaluated branches are necessary:
    * subscripting vector builtins is not allowed in constant expressions
    * if the implementation needs/uses memcpy
    * if the implementation would otherwise call SIMD intrinsics/builtins

    Signed-off-by: Matthias Kretz <m.kretz@gsi.de>

    libstdc++-v3/ChangeLog:

            PR libstdc++/109261
            * include/experimental/bits/simd.h (_SimdWrapper::_M_set):
            Avoid vector builtin subscripting in constant expressions.
            (resizing_simd_cast): Avoid memcpy if constant_evaluated.
            (const_where_expression, where_expression, where)
            (__extract_part, simd_mask, _SimdIntOperators, simd): Add either
            _GLIBCXX_SIMD_CONSTEXPR (on public APIs), or constexpr (on
            internal APIs).
            * include/experimental/bits/simd_builtin.h (__vector_permute)
            (__vector_shuffle, __extract_part, _GnuTraits::_SimdCastType1)
            (_GnuTraits::_SimdCastType2, _SimdImplBuiltin)
            (_MaskImplBuiltin::_S_store): Add constexpr.
            (_CommonImplBuiltin::_S_store_bool_array)
            (_SimdImplBuiltin::_S_load, _SimdImplBuiltin::_S_store)
            (_SimdImplBuiltin::_S_reduce, _MaskImplBuiltin::_S_load): Add
            constant_evaluated case.
            * include/experimental/bits/simd_fixed_size.h
            (_S_masked_load): Reword comment.
            (__tuple_element_meta, __make_meta, _SimdTuple::_M_apply_r)
            (_SimdTuple::_M_subscript_read, _SimdTuple::_M_subscript_write)
            (__make_simd_tuple, __optimize_simd_tuple, __extract_part)
            (__autocvt_to_simd, _Fixed::__traits::_SimdBase)
            (_Fixed::__traits::_SimdCastType, _SimdImplFixedSize): Add
            constexpr.
            (_SimdTuple::operator[], _M_set): Add constexpr and add
            constant_evaluated case.
            (_MaskImplFixedSize::_S_load): Add constant_evaluated case.
            * include/experimental/bits/simd_scalar.h: Add constexpr.
            * include/experimental/bits/simd_x86.h (_CommonImplX86): Add
            constexpr and add constant_evaluated case.
            (_SimdImplX86::_S_equal_to, _S_not_equal_to, _S_less)
            (_S_less_equal): Value-initialize to satisfy constexpr
            evaluation.
            (_MaskImplX86::_S_load): Add constant_evaluated case.
            (_MaskImplX86::_S_store): Add constexpr and constant_evaluated
            case. Value-initialize local variables.
            (_MaskImplX86::_S_logical_and, _S_logical_or, _S_bit_not)
            (_S_bit_and, _S_bit_or, _S_bit_xor): Add constant_evaluated
            case.
            * testsuite/experimental/simd/pr109261_constexpr_simd.cc: New
            test.

    (cherry picked from commit da579188807ede4ee9466d0b5bf51559c96a0b51)

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug libstdc++/109261] std::experimental::simd is not usable in several constant expressions
  2023-03-23 10:02 [Bug libstdc++/109261] New: std::experimental::simd is not usable in several constant expressions mkretz at gcc dot gnu.org
                   ` (19 preceding siblings ...)
  2023-05-25  7:05 ` cvs-commit at gcc dot gnu.org
@ 2023-05-25  7:07 ` mkretz at gcc dot gnu.org
  20 siblings, 0 replies; 22+ messages in thread
From: mkretz at gcc dot gnu.org @ 2023-05-25  7:07 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109261

Matthias Kretz (Vir) <mkretz at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #20 from Matthias Kretz (Vir) <mkretz at gcc dot gnu.org> ---
Resolved on all branches.

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2023-05-25  7:07 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-23 10:02 [Bug libstdc++/109261] New: std::experimental::simd is not usable in several constant expressions mkretz at gcc dot gnu.org
2023-03-23 10:02 ` [Bug libstdc++/109261] " mkretz at gcc dot gnu.org
2023-04-26  6:58 ` rguenth at gcc dot gnu.org
2023-05-23  7:27 ` cvs-commit at gcc dot gnu.org
2023-05-23 10:03 ` cvs-commit at gcc dot gnu.org
2023-05-23 15:14 ` clyon at gcc dot gnu.org
2023-05-23 15:37 ` mkretz at gcc dot gnu.org
2023-05-23 16:19 ` clyon at gcc dot gnu.org
2023-05-23 22:08 ` mkretz at gcc dot gnu.org
2023-05-24  8:28 ` clyon at gcc dot gnu.org
2023-05-24 11:06 ` cvs-commit at gcc dot gnu.org
2023-05-24 11:06 ` cvs-commit at gcc dot gnu.org
2023-05-24 12:31 ` clyon at gcc dot gnu.org
2023-05-24 19:41 ` cvs-commit at gcc dot gnu.org
2023-05-24 19:41 ` cvs-commit at gcc dot gnu.org
2023-05-25  7:03 ` cvs-commit at gcc dot gnu.org
2023-05-25  7:03 ` cvs-commit at gcc dot gnu.org
2023-05-25  7:04 ` cvs-commit at gcc dot gnu.org
2023-05-25  7:05 ` cvs-commit at gcc dot gnu.org
2023-05-25  7:05 ` cvs-commit at gcc dot gnu.org
2023-05-25  7:05 ` cvs-commit at gcc dot gnu.org
2023-05-25  7:07 ` mkretz at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).