Minimum example: The following code ``` #include "immintrin.h" constexpr int f() { return 0; } __m128i shuffle(__m128i x) { return _mm_shuffle_epi32(x, f()); } ``` Does not compile in debug Godbolt: https://godbolt.org/z/x7bfhr4vY
I think this is correct behavior really.
so _mm_shuffle_epi32 requires a constant but since it is an argument, the argument, it is not a constant expression requirement.
Dup of bug 80353. constexpr function does not have to be a full constexpression in many cases. *** This bug has been marked as a duplicate of bug 80353 ***
> so _mm_shuffle_epi32 requires a constant but since it is an argument, the argument, it is not a constant expression requirement. The function is marked constexpr. So it can be a constant if you ask it.
(In reply to Denis Yaroshevskiy from comment #4) > > so _mm_shuffle_epi32 requires a constant but since it is an argument, the argument, it is not a constant expression requirement. > > The function is marked constexpr. So it can be a constant if you ask it. The problem is -O0 means "don't ask it". Constant propagation is an optimization, but -O0 means don't do optimization.
(In reply to Denis Yaroshevskiy from comment #4) > > so _mm_shuffle_epi32 requires a constant but since it is an argument, the argument, it is not a constant expression requirement. > > The function is marked constexpr. So it can be a constant if you ask it. constexpr at function declaration means that it COULD be evaluated in compile time, but doesn't force it. To force it either invoke it in a context that requires a compile-time evaluation (e.g. static_assert, or initializer of constexpr variable), or mark it as consteval instead.