]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
bump: Update blake3 1.3.1 -> 71a2646
authorRafael Kitover <rkitover@gmail.com>
Tue, 23 May 2023 21:04:36 +0000 (21:04 +0000)
committerJoel Rosdahl <joel@rosdahl.net>
Tue, 6 Jun 2023 19:32:13 +0000 (21:32 +0200)
Update blake3 to master, commit 71a2646 .

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
LICENSE.adoc
src/third_party/blake3/blake3.c
src/third_party/blake3/blake3.h
src/third_party/blake3/blake3_avx2_x86-64_windows_gnu.S
src/third_party/blake3/blake3_avx512.c
src/third_party/blake3/blake3_avx512_x86-64_windows_gnu.S
src/third_party/blake3/blake3_dispatch.c
src/third_party/blake3/blake3_impl.h
src/third_party/blake3/blake3_sse2_x86-64_windows_gnu.S
src/third_party/blake3/blake3_sse41_x86-64_windows_gnu.S

index f4d26d6a7579aa9171b92f0187463fbf01fbe8d3..af8eee67dfab1959512d55deda5ef17c906acfdb 100644 (file)
@@ -72,8 +72,9 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 === src/third_party/blake3/blake3_*
 
-This is a subset of https://github.com/BLAKE3-team/BLAKE3[BLAKE3] 1.3.1 with
-the following license:
+This is a subset of https://github.com/BLAKE3-team/BLAKE3[BLAKE3] (git SHA:
+https://github.com/BLAKE3-team/BLAKE3/commit/71a2646180c787e22f8681c5fec7655a0ad51e99[71a2646])
+with the following license:
 
 ----
 This work is released into the public domain with CC0 1.0. Alternatively, it is
index 1239433c65761ea397775a336641b651b8067709..dc343f91c51be90d28cc45fa10b3604582223b29 100644 (file)
@@ -246,7 +246,7 @@ INLINE size_t compress_parents_parallel(const uint8_t *child_chaining_values,
 
 // The wide helper function returns (writes out) an array of chaining values
 // and returns the length of that array. The number of chaining values returned
-// is the dyanmically detected SIMD degree, at most MAX_SIMD_DEGREE. Or fewer,
+// is the dynamically detected SIMD degree, at most MAX_SIMD_DEGREE. Or fewer,
 // if the input is shorter than that many chunks. The reason for maintaining a
 // wide array of chaining values going back up the tree, is to allow the
 // implementation to hash as many parents in parallel as possible.
@@ -254,7 +254,7 @@ INLINE size_t compress_parents_parallel(const uint8_t *child_chaining_values,
 // As a special case when the SIMD degree is 1, this function will still return
 // at least 2 outputs. This guarantees that this function doesn't perform the
 // root compression. (If it did, it would use the wrong flags, and also we
-// wouldn't be able to implement exendable ouput.) Note that this function is
+// wouldn't be able to implement exendable output.) Note that this function is
 // not used when the whole input is only 1 chunk long; that's a different
 // codepath.
 //
index 7caf9b4b52995b7bc0563bf135066d8cd5d8dae5..b280db38834f686a97fe507b675a8d710d39eedf 100644 (file)
@@ -8,7 +8,7 @@
 extern "C" {
 #endif
 
-#define BLAKE3_VERSION_STRING "1.3.1"
+#define BLAKE3_VERSION_STRING "1.3.3"
 #define BLAKE3_KEY_LEN 32
 #define BLAKE3_OUT_LEN 32
 #define BLAKE3_BLOCK_LEN 64
index bb58d2ae64b13582c371ab5c839a2958de35c428..3d4be4a7d7cb310270ad1f51156595965c5a6f12 100644 (file)
@@ -1784,7 +1784,7 @@ blake3_hash_many_avx2:
         vmovdqu xmmword ptr [rbx+0x10], xmm1
         jmp     4b
 
-.section .rodata
+.section .rdata
 .p2align  6
 ADD0:
         .long  0, 1, 2, 3, 4, 5, 6, 7
index 9c35b08c439aee06ca96beb3f2abeca24519f5bf..334d82dc7c908ad8a064ad2a295e17d1e8bb070a 100644 (file)
@@ -1047,13 +1047,26 @@ INLINE void transpose_msg_vecs16(const uint8_t *const *inputs,
 INLINE void load_counters16(uint64_t counter, bool increment_counter,
                             __m512i *out_lo, __m512i *out_hi) {
   const __m512i mask = _mm512_set1_epi32(-(int32_t)increment_counter);
-  const __m512i add0 = _mm512_set_epi32(15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0);
-  const __m512i add1 = _mm512_and_si512(mask, add0);
-  __m512i l = _mm512_add_epi32(_mm512_set1_epi32((int32_t)counter), add1);
-  __mmask16 carry = _mm512_cmp_epu32_mask(l, add1, _MM_CMPINT_LT);
-  __m512i h = _mm512_mask_add_epi32(_mm512_set1_epi32((int32_t)(counter >> 32)), carry, _mm512_set1_epi32((int32_t)(counter >> 32)), _mm512_set1_epi32(1));
-  *out_lo = l;
-  *out_hi = h;
+  const __m512i deltas = _mm512_set_epi32(15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0);
+  const __m512i masked_deltas = _mm512_and_si512(deltas, mask);
+  const __m512i low_words = _mm512_add_epi32(
+    _mm512_set1_epi32((int32_t)counter),
+    masked_deltas);
+  // The carry bit is 1 if the high bit of the word was 1 before addition and is
+  // 0 after.
+  // NOTE: It would be a bit more natural to use _mm512_cmp_epu32_mask to
+  // compute the carry bits here, and originally we did, but that intrinsic is
+  // broken under GCC 5.4. See https://github.com/BLAKE3-team/BLAKE3/issues/271.
+  const __m512i carries = _mm512_srli_epi32(
+    _mm512_andnot_si512(
+        low_words, // 0 after (gets inverted by andnot)
+        _mm512_set1_epi32((int32_t)counter)), // and 1 before
+    31);
+  const __m512i high_words = _mm512_add_epi32(
+    _mm512_set1_epi32((int32_t)(counter >> 32)),
+    carries);
+  *out_lo = low_words;
+  *out_hi = high_words;
 }
 
 static
index e10b9f36cbccb9d95bcbe6b7fdd4c7a6255964a4..ba4fc5fa984041554ceea24af0f58d2452a79e86 100644 (file)
@@ -2587,7 +2587,7 @@ blake3_compress_xof_avx512:
         add     rsp, 72
         ret
 
-.section .rodata
+.section .rdata
 .p2align  6
 INDEX0:
         .long    0,  1,  2,  3, 16, 17, 18, 19
index b49805897a0fe31bb1a05bf273ec5589f73c2345..2ab0093ee86d2237b7aee3bff2dccf408756fc96 100644 (file)
 #elif defined(__GNUC__)
 #include <immintrin.h>
 #else
-#error "Unimplemented!"
+#undef IS_X86 /* Unimplemented! */
 #endif
 #endif
 
 #define MAYBE_UNUSED(x) (void)((x))
 
 #if defined(IS_X86)
-static uint64_t xgetbv() {
+static uint64_t xgetbv(void) {
 #if defined(_MSC_VER)
   return _xgetbv(0);
 #else
@@ -82,7 +82,7 @@ static /* Allow the variable to be controlled manually for testing */
 static
 #endif
     enum cpu_feature
-    get_cpu_features() {
+    get_cpu_features(void) {
 
   if (g_cpu_features != UNDEFINED) {
     return g_cpu_features;
@@ -101,7 +101,7 @@ static
     if (*edx & (1UL << 26))
       features |= SSE2;
 #endif
-    if (*ecx & (1UL << 0))
+    if (*ecx & (1UL << 9))
       features |= SSSE3;
     if (*ecx & (1UL << 19))
       features |= SSE41;
index cc5672f2274be24e5a92961bd2524b6ed6fb06a8..3ba9ceb046171612e9457f320e1d85918bd01c3b 100644 (file)
@@ -46,7 +46,6 @@ enum blake3_flags {
 #if defined(_MSC_VER)
 #include <intrin.h>
 #endif
-#include <immintrin.h>
 #endif
 
 #if !defined(BLAKE3_USE_NEON) 
@@ -88,7 +87,7 @@ static const uint8_t MSG_SCHEDULE[7][16] = {
 /* x is assumed to be nonzero.       */
 static unsigned int highest_one(uint64_t x) {
 #if defined(__GNUC__) || defined(__clang__)
-  return 63 ^ __builtin_clzll(x);
+  return 63 ^ (unsigned int)__builtin_clzll(x);
 #elif defined(_MSC_VER) && defined(IS_X86_64)
   unsigned long index;
   _BitScanReverse64(&index, x);
@@ -118,7 +117,7 @@ static unsigned int highest_one(uint64_t x) {
 // Count the number of 1 bits.
 INLINE unsigned int popcnt(uint64_t x) {
 #if defined(__GNUC__) || defined(__clang__)
-  return __builtin_popcountll(x);
+  return (unsigned int)__builtin_popcountll(x);
 #else
   unsigned int count = 0;
   while (x != 0) {
index 8852ba5976e15ed7c6d8ee00318bbc978e7280d1..4facb50e75bbad1f34b20013fb1e722453b48e46 100644 (file)
@@ -2301,7 +2301,7 @@ blake3_compress_xof_sse2:
         ret
 
 
-.section .rodata
+.section .rdata
 .p2align  6
 BLAKE3_IV:
         .long  0x6A09E667, 0xBB67AE85
index 60d0a4042e71dd6562fd887ed039e53a9ef9d0c2..02083f9d59231abddd5fda2f2af19983069e01f9 100644 (file)
@@ -2042,7 +2042,7 @@ blake3_compress_xof_sse41:
         ret
 
 
-.section .rodata
+.section .rdata
 .p2align  6
 BLAKE3_IV:
         .long  0x6A09E667, 0xBB67AE85