Skip to content

Commit 48db7ef

Browse files
RKSimonDanielCChen
authored andcommitted
[clang][x86] Add constexpr support for some basic SSE2 fp intrinsics
Followup to llvm#111001
1 parent b579fec commit 48db7ef

File tree

2 files changed

+150
-48
lines changed

2 files changed

+150
-48
lines changed

clang/lib/Headers/emmintrin.h

Lines changed: 55 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ typedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));
8686
/// \returns A 128-bit vector of [2 x double] whose lower 64 bits contain the
8787
/// sum of the lower 64 bits of both operands. The upper 64 bits are copied
8888
/// from the upper 64 bits of the first source operand.
89-
static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_add_sd(__m128d __a,
90-
__m128d __b) {
89+
static __inline__ __m128d __DEFAULT_FN_ATTRS_CONSTEXPR _mm_add_sd(__m128d __a,
90+
__m128d __b) {
9191
__a[0] += __b[0];
9292
return __a;
9393
}
@@ -104,8 +104,8 @@ static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_add_sd(__m128d __a,
104104
/// A 128-bit vector of [2 x double] containing one of the source operands.
105105
/// \returns A 128-bit vector of [2 x double] containing the sums of both
106106
/// operands.
107-
static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_add_pd(__m128d __a,
108-
__m128d __b) {
107+
static __inline__ __m128d __DEFAULT_FN_ATTRS_CONSTEXPR _mm_add_pd(__m128d __a,
108+
__m128d __b) {
109109
return (__m128d)((__v2df)__a + (__v2df)__b);
110110
}
111111

@@ -126,8 +126,8 @@ static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_add_pd(__m128d __a,
126126
/// \returns A 128-bit vector of [2 x double] whose lower 64 bits contain the
127127
/// difference of the lower 64 bits of both operands. The upper 64 bits are
128128
/// copied from the upper 64 bits of the first source operand.
129-
static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_sub_sd(__m128d __a,
130-
__m128d __b) {
129+
static __inline__ __m128d __DEFAULT_FN_ATTRS_CONSTEXPR _mm_sub_sd(__m128d __a,
130+
__m128d __b) {
131131
__a[0] -= __b[0];
132132
return __a;
133133
}
@@ -144,8 +144,8 @@ static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_sub_sd(__m128d __a,
144144
/// A 128-bit vector of [2 x double] containing the subtrahend.
145145
/// \returns A 128-bit vector of [2 x double] containing the differences between
146146
/// both operands.
147-
static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_sub_pd(__m128d __a,
148-
__m128d __b) {
147+
static __inline__ __m128d __DEFAULT_FN_ATTRS_CONSTEXPR _mm_sub_pd(__m128d __a,
148+
__m128d __b) {
149149
return (__m128d)((__v2df)__a - (__v2df)__b);
150150
}
151151

@@ -165,8 +165,8 @@ static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_sub_pd(__m128d __a,
165165
/// \returns A 128-bit vector of [2 x double] whose lower 64 bits contain the
166166
/// product of the lower 64 bits of both operands. The upper 64 bits are
167167
/// copied from the upper 64 bits of the first source operand.
168-
static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_mul_sd(__m128d __a,
169-
__m128d __b) {
168+
static __inline__ __m128d __DEFAULT_FN_ATTRS_CONSTEXPR _mm_mul_sd(__m128d __a,
169+
__m128d __b) {
170170
__a[0] *= __b[0];
171171
return __a;
172172
}
@@ -183,8 +183,8 @@ static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_mul_sd(__m128d __a,
183183
/// A 128-bit vector of [2 x double] containing one of the operands.
184184
/// \returns A 128-bit vector of [2 x double] containing the products of both
185185
/// operands.
186-
static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_mul_pd(__m128d __a,
187-
__m128d __b) {
186+
static __inline__ __m128d __DEFAULT_FN_ATTRS_CONSTEXPR _mm_mul_pd(__m128d __a,
187+
__m128d __b) {
188188
return (__m128d)((__v2df)__a * (__v2df)__b);
189189
}
190190

@@ -205,8 +205,8 @@ static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_mul_pd(__m128d __a,
205205
/// \returns A 128-bit vector of [2 x double] whose lower 64 bits contain the
206206
/// quotient of the lower 64 bits of both operands. The upper 64 bits are
207207
/// copied from the upper 64 bits of the first source operand.
208-
static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_div_sd(__m128d __a,
209-
__m128d __b) {
208+
static __inline__ __m128d __DEFAULT_FN_ATTRS_CONSTEXPR _mm_div_sd(__m128d __a,
209+
__m128d __b) {
210210
__a[0] /= __b[0];
211211
return __a;
212212
}
@@ -224,8 +224,8 @@ static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_div_sd(__m128d __a,
224224
/// A 128-bit vector of [2 x double] containing the divisor.
225225
/// \returns A 128-bit vector of [2 x double] containing the quotients of both
226226
/// operands.
227-
static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_div_pd(__m128d __a,
228-
__m128d __b) {
227+
static __inline__ __m128d __DEFAULT_FN_ATTRS_CONSTEXPR _mm_div_pd(__m128d __a,
228+
__m128d __b) {
229229
return (__m128d)((__v2df)__a / (__v2df)__b);
230230
}
231231

@@ -373,8 +373,8 @@ static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_max_pd(__m128d __a,
373373
/// A 128-bit vector of [2 x double] containing one of the source operands.
374374
/// \returns A 128-bit vector of [2 x double] containing the bitwise AND of the
375375
/// values between both operands.
376-
static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_and_pd(__m128d __a,
377-
__m128d __b) {
376+
static __inline__ __m128d __DEFAULT_FN_ATTRS_CONSTEXPR _mm_and_pd(__m128d __a,
377+
__m128d __b) {
378378
return (__m128d)((__v2du)__a & (__v2du)__b);
379379
}
380380

@@ -393,8 +393,8 @@ static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_and_pd(__m128d __a,
393393
/// \returns A 128-bit vector of [2 x double] containing the bitwise AND of the
394394
/// values in the second operand and the one's complement of the first
395395
/// operand.
396-
static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_andnot_pd(__m128d __a,
397-
__m128d __b) {
396+
static __inline__ __m128d __DEFAULT_FN_ATTRS_CONSTEXPR
397+
_mm_andnot_pd(__m128d __a, __m128d __b) {
398398
return (__m128d)(~(__v2du)__a & (__v2du)__b);
399399
}
400400

@@ -410,8 +410,8 @@ static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_andnot_pd(__m128d __a,
410410
/// A 128-bit vector of [2 x double] containing one of the source operands.
411411
/// \returns A 128-bit vector of [2 x double] containing the bitwise OR of the
412412
/// values between both operands.
413-
static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_or_pd(__m128d __a,
414-
__m128d __b) {
413+
static __inline__ __m128d __DEFAULT_FN_ATTRS_CONSTEXPR _mm_or_pd(__m128d __a,
414+
__m128d __b) {
415415
return (__m128d)((__v2du)__a | (__v2du)__b);
416416
}
417417

@@ -427,8 +427,8 @@ static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_or_pd(__m128d __a,
427427
/// A 128-bit vector of [2 x double] containing one of the source operands.
428428
/// \returns A 128-bit vector of [2 x double] containing the bitwise XOR of the
429429
/// values between both operands.
430-
static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_xor_pd(__m128d __a,
431-
__m128d __b) {
430+
static __inline__ __m128d __DEFAULT_FN_ATTRS_CONSTEXPR _mm_xor_pd(__m128d __a,
431+
__m128d __b) {
432432
return (__m128d)((__v2du)__a ^ (__v2du)__b);
433433
}
434434

@@ -1306,7 +1306,8 @@ static __inline__ __m128 __DEFAULT_FN_ATTRS _mm_cvtpd_ps(__m128d __a) {
13061306
/// floating-point elements are converted to double-precision values. The
13071307
/// upper two elements are unused.
13081308
/// \returns A 128-bit vector of [2 x double] containing the converted values.
1309-
static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_cvtps_pd(__m128 __a) {
1309+
static __inline__ __m128d __DEFAULT_FN_ATTRS_CONSTEXPR
1310+
_mm_cvtps_pd(__m128 __a) {
13101311
return (__m128d) __builtin_convertvector(
13111312
__builtin_shufflevector((__v4sf)__a, (__v4sf)__a, 0, 1), __v2df);
13121313
}
@@ -1327,7 +1328,8 @@ static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_cvtps_pd(__m128 __a) {
13271328
///
13281329
/// The upper two elements are unused.
13291330
/// \returns A 128-bit vector of [2 x double] containing the converted values.
1330-
static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_cvtepi32_pd(__m128i __a) {
1331+
static __inline__ __m128d __DEFAULT_FN_ATTRS_CONSTEXPR
1332+
_mm_cvtepi32_pd(__m128i __a) {
13311333
return (__m128d) __builtin_convertvector(
13321334
__builtin_shufflevector((__v4si)__a, (__v4si)__a, 0, 1), __v2df);
13331335
}
@@ -1413,8 +1415,8 @@ static __inline__ __m128 __DEFAULT_FN_ATTRS _mm_cvtsd_ss(__m128 __a,
14131415
/// \returns A 128-bit vector of [2 x double]. The lower 64 bits contain the
14141416
/// converted value from the second parameter. The upper 64 bits are copied
14151417
/// from the upper 64 bits of the first parameter.
1416-
static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_cvtsi32_sd(__m128d __a,
1417-
int __b) {
1418+
static __inline__ __m128d __DEFAULT_FN_ATTRS_CONSTEXPR
1419+
_mm_cvtsi32_sd(__m128d __a, int __b) {
14181420
__a[0] = __b;
14191421
return __a;
14201422
}
@@ -1438,8 +1440,8 @@ static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_cvtsi32_sd(__m128d __a,
14381440
/// \returns A 128-bit vector of [2 x double]. The lower 64 bits contain the
14391441
/// converted value from the second parameter. The upper 64 bits are copied
14401442
/// from the upper 64 bits of the first parameter.
1441-
static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_cvtss_sd(__m128d __a,
1442-
__m128 __b) {
1443+
static __inline__ __m128d __DEFAULT_FN_ATTRS_CONSTEXPR
1444+
_mm_cvtss_sd(__m128d __a, __m128 __b) {
14431445
__a[0] = __b[0];
14441446
return __a;
14451447
}
@@ -1535,7 +1537,8 @@ static __inline__ __m64 __DEFAULT_FN_ATTRS _mm_cvttpd_pi32(__m128d __a) {
15351537
/// \param __a
15361538
/// A 64-bit vector of [2 x i32].
15371539
/// \returns A 128-bit vector of [2 x double] containing the converted values.
1538-
static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_cvtpi32_pd(__m64 __a) {
1540+
static __inline__ __m128d __DEFAULT_FN_ATTRS_CONSTEXPR
1541+
_mm_cvtpi32_pd(__m64 __a) {
15391542
return (__m128d) __builtin_convertvector((__v2si)__a, __v2df);
15401543
}
15411544

@@ -1550,7 +1553,8 @@ static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_cvtpi32_pd(__m64 __a) {
15501553
/// A 128-bit vector of [2 x double]. The lower 64 bits are returned.
15511554
/// \returns A double-precision floating-point value copied from the lower 64
15521555
/// bits of \a __a.
1553-
static __inline__ double __DEFAULT_FN_ATTRS _mm_cvtsd_f64(__m128d __a) {
1556+
static __inline__ double __DEFAULT_FN_ATTRS_CONSTEXPR
1557+
_mm_cvtsd_f64(__m128d __a) {
15541558
return __a[0];
15551559
}
15561560

@@ -1785,7 +1789,7 @@ static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_undefined_pd(void) {
17851789
/// \returns An initialized 128-bit floating-point vector of [2 x double]. The
17861790
/// lower 64 bits contain the value of the parameter. The upper 64 bits are
17871791
/// set to zero.
1788-
static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_set_sd(double __w) {
1792+
static __inline__ __m128d __DEFAULT_FN_ATTRS_CONSTEXPR _mm_set_sd(double __w) {
17891793
return __extension__(__m128d){__w, 0.0};
17901794
}
17911795

@@ -1801,7 +1805,7 @@ static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_set_sd(double __w) {
18011805
/// A double-precision floating-point value used to initialize each vector
18021806
/// element of the result.
18031807
/// \returns An initialized 128-bit floating-point vector of [2 x double].
1804-
static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_set1_pd(double __w) {
1808+
static __inline__ __m128d __DEFAULT_FN_ATTRS_CONSTEXPR _mm_set1_pd(double __w) {
18051809
return __extension__(__m128d){__w, __w};
18061810
}
18071811

@@ -1817,7 +1821,7 @@ static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_set1_pd(double __w) {
18171821
/// A double-precision floating-point value used to initialize each vector
18181822
/// element of the result.
18191823
/// \returns An initialized 128-bit floating-point vector of [2 x double].
1820-
static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_set_pd1(double __w) {
1824+
static __inline__ __m128d __DEFAULT_FN_ATTRS_CONSTEXPR _mm_set_pd1(double __w) {
18211825
return _mm_set1_pd(__w);
18221826
}
18231827

@@ -1835,8 +1839,8 @@ static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_set_pd1(double __w) {
18351839
/// A double-precision floating-point value used to initialize the lower 64
18361840
/// bits of the result.
18371841
/// \returns An initialized 128-bit floating-point vector of [2 x double].
1838-
static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_set_pd(double __w,
1839-
double __x) {
1842+
static __inline__ __m128d __DEFAULT_FN_ATTRS_CONSTEXPR _mm_set_pd(double __w,
1843+
double __x) {
18401844
return __extension__(__m128d){__x, __w};
18411845
}
18421846

@@ -1855,8 +1859,8 @@ static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_set_pd(double __w,
18551859
/// A double-precision floating-point value used to initialize the upper 64
18561860
/// bits of the result.
18571861
/// \returns An initialized 128-bit floating-point vector of [2 x double].
1858-
static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_setr_pd(double __w,
1859-
double __x) {
1862+
static __inline__ __m128d __DEFAULT_FN_ATTRS_CONSTEXPR _mm_setr_pd(double __w,
1863+
double __x) {
18601864
return __extension__(__m128d){__w, __x};
18611865
}
18621866

@@ -1888,8 +1892,8 @@ static __inline__ __m128d __DEFAULT_FN_ATTRS_CONSTEXPR _mm_setzero_pd(void) {
18881892
/// A 128-bit vector of [2 x double]. The lower 64 bits are written to the
18891893
/// lower 64 bits of the result.
18901894
/// \returns A 128-bit vector of [2 x double] containing the moved values.
1891-
static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_move_sd(__m128d __a,
1892-
__m128d __b) {
1895+
static __inline__ __m128d __DEFAULT_FN_ATTRS_CONSTEXPR
1896+
_mm_move_sd(__m128d __a, __m128d __b) {
18931897
__a[0] = __b[0];
18941898
return __a;
18951899
}
@@ -3323,7 +3327,8 @@ static __inline__ long long __DEFAULT_FN_ATTRS _mm_cvttsd_si64(__m128d __a) {
33233327
/// \param __a
33243328
/// A 128-bit integer vector.
33253329
/// \returns A 128-bit vector of [4 x float] containing the converted values.
3326-
static __inline__ __m128 __DEFAULT_FN_ATTRS _mm_cvtepi32_ps(__m128i __a) {
3330+
static __inline__ __m128 __DEFAULT_FN_ATTRS_CONSTEXPR
3331+
_mm_cvtepi32_ps(__m128i __a) {
33273332
return (__m128) __builtin_convertvector((__v4si)__a, __v4sf);
33283333
}
33293334

@@ -4651,8 +4656,8 @@ static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_move_epi64(__m128i __a) {
46514656
/// A 128-bit vector of [2 x double]. \n
46524657
/// Bits [127:64] are written to bits [127:64] of the destination.
46534658
/// \returns A 128-bit vector of [2 x double] containing the interleaved values.
4654-
static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_unpackhi_pd(__m128d __a,
4655-
__m128d __b) {
4659+
static __inline__ __m128d __DEFAULT_FN_ATTRS_CONSTEXPR
4660+
_mm_unpackhi_pd(__m128d __a, __m128d __b) {
46564661
return __builtin_shufflevector((__v2df)__a, (__v2df)__b, 1, 2 + 1);
46574662
}
46584663

@@ -4671,8 +4676,8 @@ static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_unpackhi_pd(__m128d __a,
46714676
/// A 128-bit vector of [2 x double]. \n
46724677
/// Bits [63:0] are written to bits [127:64] of the destination.
46734678
/// \returns A 128-bit vector of [2 x double] containing the interleaved values.
4674-
static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_unpacklo_pd(__m128d __a,
4675-
__m128d __b) {
4679+
static __inline__ __m128d __DEFAULT_FN_ATTRS_CONSTEXPR
4680+
_mm_unpacklo_pd(__m128d __a, __m128d __b) {
46764681
return __builtin_shufflevector((__v2df)__a, (__v2df)__b, 0, 2 + 0);
46774682
}
46784683

@@ -4735,7 +4740,8 @@ static __inline__ int __DEFAULT_FN_ATTRS _mm_movemask_pd(__m128d __a) {
47354740
/// A 128-bit floating-point vector of [2 x double].
47364741
/// \returns A 128-bit floating-point vector of [4 x float] containing the same
47374742
/// bitwise pattern as the parameter.
4738-
static __inline__ __m128 __DEFAULT_FN_ATTRS _mm_castpd_ps(__m128d __a) {
4743+
static __inline__ __m128 __DEFAULT_FN_ATTRS_CONSTEXPR
4744+
_mm_castpd_ps(__m128d __a) {
47394745
return (__m128)__a;
47404746
}
47414747

@@ -4750,7 +4756,8 @@ static __inline__ __m128 __DEFAULT_FN_ATTRS _mm_castpd_ps(__m128d __a) {
47504756
/// A 128-bit floating-point vector of [2 x double].
47514757
/// \returns A 128-bit integer vector containing the same bitwise pattern as the
47524758
/// parameter.
4753-
static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_castpd_si128(__m128d __a) {
4759+
static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR
4760+
_mm_castpd_si128(__m128d __a) {
47544761
return (__m128i)__a;
47554762
}
47564763

0 commit comments

Comments
 (0)