enc_avx2.c 567 B

12345678910111213141516171819202122
  1. // If we have AVX2 support, pick off 24 bytes at a time for as long as we can.
  2. // But because we read 32 bytes at a time, ensure we have enough room to do a
  3. // full 32-byte read without segfaulting:
  4. while (srclen >= 32)
  5. {
  6. // Load string:
  7. __m256i str = _mm256_loadu_si256((__m256i *)c);
  8. // Reshuffle:
  9. str = enc_reshuffle(str);
  10. // Translate reshuffled bytes to the Base64 alphabet:
  11. str = enc_translate(str);
  12. // Store:
  13. _mm256_storeu_si256((__m256i *)o, str);
  14. c += 24; // 6 * 4 bytes of input
  15. o += 32; // 8 * 4 bytes of output
  16. outl += 32;
  17. srclen -= 24;
  18. }