Skip to content

[Headers][X86] Allow _mm512_set1_epi8/16/pd/ps intrinsics to be used in constexpr #152746

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions clang/lib/Headers/avx512fintrin.h
Original file line number Diff line number Diff line change
Expand Up @@ -277,20 +277,20 @@ _mm512_setzero_pd(void) {
return __extension__(__m512d){0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
}

static __inline __m512 __DEFAULT_FN_ATTRS512
static __inline __m512 __DEFAULT_FN_ATTRS512_CONSTEXPR
_mm512_set1_ps(float __w)
{
return __extension__ (__m512){ __w, __w, __w, __w, __w, __w, __w, __w,
__w, __w, __w, __w, __w, __w, __w, __w };
}

static __inline __m512d __DEFAULT_FN_ATTRS512
static __inline __m512d __DEFAULT_FN_ATTRS512_CONSTEXPR
_mm512_set1_pd(double __w)
{
return __extension__ (__m512d){ __w, __w, __w, __w, __w, __w, __w, __w };
}

static __inline __m512i __DEFAULT_FN_ATTRS512
static __inline __m512i __DEFAULT_FN_ATTRS512_CONSTEXPR
_mm512_set1_epi8(char __w)
{
return __extension__ (__m512i)(__v64qi){
Expand All @@ -304,7 +304,7 @@ _mm512_set1_epi8(char __w)
__w, __w, __w, __w, __w, __w, __w, __w };
}

static __inline __m512i __DEFAULT_FN_ATTRS512
static __inline __m512i __DEFAULT_FN_ATTRS512_CONSTEXPR
_mm512_set1_epi16(short __w)
{
return __extension__ (__m512i)(__v32hi){
Expand Down
18 changes: 18 additions & 0 deletions clang/test/CodeGen/X86/avx512f-builtins.c
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,22 @@ __m512d test_mm512_set1_pd(double d)
// CHECK: insertelement <8 x double> {{.*}}, i32 7
return _mm512_set1_pd(d);
}
TEST_CONSTEXPR(match_m512d(_mm512_set1_pd(-100.0), -100.0, -100.0, -100.0, -100.0, -100.0, -100.0, -100.0, -100.0));

__m512 test_mm512_set1_ps(float d)
{
// CHECK-LABEL: test_mm512_set1_ps
// CHECK: insertelement <16 x float> {{.*}}, i32 0
// CHECK: insertelement <16 x float> {{.*}}, i32 1
// CHECK: insertelement <16 x float> {{.*}}, i32 2
// CHECK: insertelement <16 x float> {{.*}}, i32 3
// CHECK: insertelement <16 x float> {{.*}}, i32 4
// CHECK: insertelement <16 x float> {{.*}}, i32 5
// CHECK: insertelement <16 x float> {{.*}}, i32 6
// CHECK: insertelement <16 x float> {{.*}}, i32 15
return _mm512_set1_ps(d);
}
TEST_CONSTEXPR(match_m512(_mm512_set1_ps(-55.0f), -55.0f, -55.0f, -55.0f, -55.0f, -55.0f, -55.0f, -55.0f, -55.0f, -55.0f, -55.0f, -55.0f, -55.0f, -55.0f, -55.0f, -55.0f, -55.0f));

__mmask16 test_mm512_knot(__mmask16 a)
{
Expand Down Expand Up @@ -9046,6 +9062,7 @@ __m512i test_mm512_set1_epi8(char d)
// CHECK: insertelement <64 x i8> {{.*}}, i32 63
return _mm512_set1_epi8(d);
}
TEST_CONSTEXPR(match_v64qi(_mm512_set1_epi8(127), 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127));

__m512i test_mm512_set1_epi16(short d)
{
Expand All @@ -9061,6 +9078,7 @@ __m512i test_mm512_set1_epi16(short d)
// CHECK: insertelement <32 x i16> {{.*}}, i32 31
return _mm512_set1_epi16(d);
}
TEST_CONSTEXPR(match_v32hi(_mm512_set1_epi16(-511), -511, -511, -511, -511, -511, -511, -511, -511, -511, -511, -511, -511, -511, -511, -511, -511, -511, -511, -511, -511, -511, -511, -511, -511, -511, -511, -511, -511, -511, -511, -511, -511));

__m512i test_mm512_set1_epi32(int d)
{
Expand Down
Loading