]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
Rewrite Fix to Still Auto-Vectorize 2850/head
authorW. Felix Handte <w@felixhandte.com>
Tue, 9 Nov 2021 17:15:18 +0000 (12:15 -0500)
committerW. Felix Handte <w@felixhandte.com>
Tue, 9 Nov 2021 17:17:03 +0000 (12:17 -0500)
lib/compress/zstd_compress.c

index 59a21691839ff0df70c8fc3932ba173908d78c04..09f18d6d94571b961c1dd4790743740420e3c2e0 100644 (file)
@@ -2332,12 +2332,17 @@ ZSTD_reduceTable_internal (U32* const table, U32 const size, U32 const reducerVa
     for (rowNb=0 ; rowNb < nbRows ; rowNb++) {
         int column;
         for (column=0; column<ZSTD_ROWSIZE; column++) {
+            U32 newVal;
             if (preserveMark && table[cellNb] == ZSTD_DUBT_UNSORTED_MARK) {
+                /* This write is pointless, but is required(?) for the compiler
+                 * to auto-vectorize the loop. */
+                newVal = ZSTD_DUBT_UNSORTED_MARK;
             } else if (table[cellNb] < reducerThreshold) {
-                table[cellNb] = 0;
+                newVal = 0;
             } else {
-                table[cellNb] -= reducerValue;
+                newVal = table[cellNb] - reducerValue;
             }
+            table[cellNb] = newVal;
             cellNb++;
     }   }
 }