Created
February 17, 2021 18:45
-
-
Save Const-me/7d1ce74a8bbfbe75d20ff0b935c1660f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
inline __m256i shiftLeftBytes_mem( const __m256i src, int i ) | |
{ | |
assert( i >= 0 && i < 32 ); | |
// Align by 64 bytes so the complete array stays in a single cache line | |
alignas( 64 ) std::array<uint8_t, 64> buffer; | |
// Store zeros at offset 0 | |
_mm256_store_si256( ( __m256i* )buffer.data(), _mm256_setzero_si256() ); | |
// Store the source vector at offset 32 | |
_mm256_store_si256( ( __m256i* )( buffer.data() + 32 ), src ); | |
// Load back with the offset | |
return _mm256_loadu_si256( ( const __m256i* )( buffer.data() + 32 - i ) ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment