// Loads and stores to do away with the tedium of casting the address // to the right type. staticinline __m128i xx_loadl_32(constvoid *a) { int val;
memcpy(&val, a, sizeof(val)); return _mm_cvtsi32_si128(val);
}
// _mm_loadu_si64 has been introduced in GCC 9, reimplement the function // manually on older compilers. #if !defined(__clang__) && __GNUC_MAJOR__ < 9 staticinline __m128i xx_loadu_2x64(constvoid *hi, constvoid *lo) {
__m64 hi_, lo_;
memcpy(&hi_, hi, sizeof(hi_));
memcpy(&lo_, lo, sizeof(lo_)); return _mm_set_epi64(hi_, lo_);
} #else // Load 64 bits from each of hi and low, and pack into an SSE register // Since directly loading as `int64_t`s and using _mm_set_epi64 may violate // the strict aliasing rule, this takes a different approach staticinline __m128i xx_loadu_2x64(constvoid *hi, constvoid *lo) { return _mm_unpacklo_epi64(_mm_loadl_epi64((const __m128i *)lo),
_mm_loadl_epi64((const __m128i *)hi));
} #endif
staticinlinevoid xx_storel_16(void *const a, const __m128i v) { const uint16_t val = (uint16_t)_mm_cvtsi128_si32(v);
memcpy(a, &val, sizeof(val));
}
staticinlinevoid xx_storel_32(void *const a, const __m128i v) { constint val = _mm_cvtsi128_si32(v);
memcpy(a, &val, sizeof(val));
}
// Fill an SSE register using an interleaved pair of values, ie. set the // 8 channels to {a, b, a, b, a, b, a, b}, using the same channel ordering // as when a register is stored to / loaded from memory. // // This is useful for rearranging filter kernels for use with the _mm_madd_epi16 // instruction staticinline __m128i xx_set2_epi16(int16_t a, int16_t b) { return _mm_setr_epi16(a, b, a, b, a, b, a, b);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.