Skip to content

Commit 03baa0a

Browse files
committed
[clang][x86] Add constexpr support for _mm256_set_pd/_mm256_set_ps/_mm256_set1_pd/_mm256_set1_ps/_mm256_setr_pd/_mm256_setr_ps
1 parent 8449bf3 commit 03baa0a

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

clang/lib/Headers/avxintrin.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3706,7 +3706,7 @@ _mm256_undefined_si256(void)
37063706
/// A double-precision floating-point value used to initialize bits [63:0]
37073707
/// of the result.
37083708
/// \returns An initialized 256-bit floating-point vector of [4 x double].
3709-
static __inline __m256d __DEFAULT_FN_ATTRS
3709+
static __inline __m256d __DEFAULT_FN_ATTRS_CONSTEXPR
37103710
_mm256_set_pd(double __a, double __b, double __c, double __d)
37113711
{
37123712
return __extension__ (__m256d){ __d, __c, __b, __a };
@@ -3745,7 +3745,7 @@ _mm256_set_pd(double __a, double __b, double __c, double __d)
37453745
/// A single-precision floating-point value used to initialize bits [31:0]
37463746
/// of the result.
37473747
/// \returns An initialized 256-bit floating-point vector of [8 x float].
3748-
static __inline __m256 __DEFAULT_FN_ATTRS
3748+
static __inline __m256 __DEFAULT_FN_ATTRS_CONSTEXPR
37493749
_mm256_set_ps(float __a, float __b, float __c, float __d,
37503750
float __e, float __f, float __g, float __h)
37513751
{
@@ -3972,7 +3972,7 @@ _mm256_set_epi64x(long long __a, long long __b, long long __c, long long __d)
39723972
/// A double-precision floating-point value used to initialize bits [255:192]
39733973
/// of the result.
39743974
/// \returns An initialized 256-bit floating-point vector of [4 x double].
3975-
static __inline __m256d __DEFAULT_FN_ATTRS
3975+
static __inline __m256d __DEFAULT_FN_ATTRS_CONSTEXPR
39763976
_mm256_setr_pd(double __a, double __b, double __c, double __d)
39773977
{
39783978
return _mm256_set_pd(__d, __c, __b, __a);
@@ -4012,7 +4012,7 @@ _mm256_setr_pd(double __a, double __b, double __c, double __d)
40124012
/// A single-precision floating-point value used to initialize bits [255:224]
40134013
/// of the result.
40144014
/// \returns An initialized 256-bit floating-point vector of [8 x float].
4015-
static __inline __m256 __DEFAULT_FN_ATTRS
4015+
static __inline __m256 __DEFAULT_FN_ATTRS_CONSTEXPR
40164016
_mm256_setr_ps(float __a, float __b, float __c, float __d,
40174017
float __e, float __f, float __g, float __h)
40184018
{
@@ -4229,7 +4229,7 @@ _mm256_setr_epi64x(long long __a, long long __b, long long __c, long long __d)
42294229
/// A double-precision floating-point value used to initialize each vector
42304230
/// element of the result.
42314231
/// \returns An initialized 256-bit floating-point vector of [4 x double].
4232-
static __inline __m256d __DEFAULT_FN_ATTRS
4232+
static __inline __m256d __DEFAULT_FN_ATTRS_CONSTEXPR
42334233
_mm256_set1_pd(double __w)
42344234
{
42354235
return _mm256_set_pd(__w, __w, __w, __w);
@@ -4248,7 +4248,7 @@ _mm256_set1_pd(double __w)
42484248
/// A single-precision floating-point value used to initialize each vector
42494249
/// element of the result.
42504250
/// \returns An initialized 256-bit floating-point vector of [8 x float].
4251-
static __inline __m256 __DEFAULT_FN_ATTRS
4251+
static __inline __m256 __DEFAULT_FN_ATTRS_CONSTEXPR
42524252
_mm256_set1_ps(float __w)
42534253
{
42544254
return _mm256_set_ps(__w, __w, __w, __w, __w, __w, __w, __w);

clang/test/CodeGen/X86/avx-builtins.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1496,6 +1496,7 @@ __m256d test_mm256_set_pd(double A0, double A1, double A2, double A3) {
14961496
// CHECK: insertelement <4 x double> %{{.*}}, double %{{.*}}, i32 3
14971497
return _mm256_set_pd(A0, A1, A2, A3);
14981498
}
1499+
TEST_CONSTEXPR(match_m256d(_mm256_set_pd(-100.0, +90.0, -50.0, +1.0), +1.0, -50.0, +90.0, -100.0));
14991500

15001501
__m256 test_mm256_set_ps(float A0, float A1, float A2, float A3, float A4, float A5, float A6, float A7) {
15011502
// CHECK-LABEL: test_mm256_set_ps
@@ -1509,6 +1510,7 @@ __m256 test_mm256_set_ps(float A0, float A1, float A2, float A3, float A4, float
15091510
// CHECK: insertelement <8 x float> %{{.*}}, float %{{.*}}, i32 7
15101511
return _mm256_set_ps(A0, A1, A2, A3, A4, A5, A6, A7);
15111512
}
1513+
TEST_CONSTEXPR(match_m256(_mm256_set_ps(-1.0f, +2.0f, -3.0f, +4.0f, -5.0f, +6.0f, -7.0f, +8.0f), +8.0f, -7.0f, +6.0f, -5.0f, +4.0f, -3.0f, +2.0f, -1.0f));
15121514

15131515
__m256i test_mm256_set1_epi8(char A) {
15141516
// CHECK-LABEL: test_mm256_set1_epi8
@@ -1598,6 +1600,7 @@ __m256d test_mm256_set1_pd(double A) {
15981600
// CHECK: insertelement <4 x double> %{{.*}}, double %{{.*}}, i32 3
15991601
return _mm256_set1_pd(A);
16001602
}
1603+
TEST_CONSTEXPR(match_m256d(_mm256_set1_pd(+42.0), +42.0, +42.0, +42.0, +42.0));
16011604

16021605
__m256 test_mm256_set1_ps(float A) {
16031606
// CHECK-LABEL: test_mm256_set1_ps
@@ -1611,6 +1614,7 @@ __m256 test_mm256_set1_ps(float A) {
16111614
// CHECK: insertelement <8 x float> %{{.*}}, float %{{.*}}, i32 7
16121615
return _mm256_set1_ps(A);
16131616
}
1617+
TEST_CONSTEXPR(match_m256(_mm256_set1_ps(-101.0f), -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f));
16141618

16151619
__m256i test_mm256_setr_epi8(char A0, char A1, char A2, char A3, char A4, char A5, char A6, char A7,
16161620
char A8, char A9, char A10, char A11, char A12, char A13, char A14, char A15,
@@ -1722,6 +1726,7 @@ __m256d test_mm256_setr_pd(double A0, double A1, double A2, double A3) {
17221726
// CHECK: insertelement <4 x double> %{{.*}}, double %{{.*}}, i32 3
17231727
return _mm256_setr_pd(A0, A1, A2, A3);
17241728
}
1729+
TEST_CONSTEXPR(match_m256d(_mm256_setr_pd(-100.0, +90.0, -50.0, +1.0), -100.0, +90.0, -50.0, +1.0));
17251730

17261731
__m256 test_mm256_setr_ps(float A0, float A1, float A2, float A3, float A4, float A5, float A6, float A7) {
17271732
// CHECK-LABEL: test_mm256_setr_ps
@@ -1735,6 +1740,7 @@ __m256 test_mm256_setr_ps(float A0, float A1, float A2, float A3, float A4, floa
17351740
// CHECK: insertelement <8 x float> %{{.*}}, float %{{.*}}, i32 7
17361741
return _mm256_setr_ps(A0, A1, A2, A3, A4, A5, A6, A7);
17371742
}
1743+
TEST_CONSTEXPR(match_m256(_mm256_setr_ps(-1.0f, +2.0f, -3.0f, +4.0f, -5.0f, +6.0f, -7.0f, +8.0f), -1.0f, +2.0f, -3.0f, +4.0f, -5.0f, +6.0f, -7.0f, +8.0f));
17381744

17391745
__m256d test_mm256_setzero_pd(void) {
17401746
// CHECK-LABEL: test_mm256_setzero_pd

0 commit comments

Comments
 (0)