MCPcopy Create free account
hub / github.com/numpy/numpy / libdivide_mullhi_u64_vector

Function libdivide_mullhi_u64_vector

numpy/core/include/numpy/libdivide/libdivide.h:1251–1269  ·  view source on GitHub ↗

Here, y is assumed to contain one 64-bit value repeated. https://stackoverflow.com/a/28827013

Source from the content-addressed store, hash-verified

1249// Here, y is assumed to contain one 64-bit value repeated.
1250// https://stackoverflow.com/a/28827013
1251static inline __m512i libdivide_mullhi_u64_vector(__m512i x, __m512i y) {
1252 __m512i lomask = _mm512_set1_epi64(0xffffffff);
1253 __m512i xh = _mm512_shuffle_epi32(x, (_MM_PERM_ENUM) 0xB1);
1254 __m512i yh = _mm512_shuffle_epi32(y, (_MM_PERM_ENUM) 0xB1);
1255 __m512i w0 = _mm512_mul_epu32(x, y);
1256 __m512i w1 = _mm512_mul_epu32(x, yh);
1257 __m512i w2 = _mm512_mul_epu32(xh, y);
1258 __m512i w3 = _mm512_mul_epu32(xh, yh);
1259 __m512i w0h = _mm512_srli_epi64(w0, 32);
1260 __m512i s1 = _mm512_add_epi64(w1, w0h);
1261 __m512i s1l = _mm512_and_si512(s1, lomask);
1262 __m512i s1h = _mm512_srli_epi64(s1, 32);
1263 __m512i s2 = _mm512_add_epi64(w2, s1l);
1264 __m512i s2h = _mm512_srli_epi64(s2, 32);
1265 __m512i hi = _mm512_add_epi64(w3, s1h);
1266 hi = _mm512_add_epi64(hi, s2h);
1267
1268 return hi;
1269}
1270
1271// y is one 64-bit value repeated.
1272static inline __m512i libdivide_mullhi_s64_vector(__m512i x, __m512i y) {

Callers 3

libdivide_u64_do_vectorFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected