]> git.proxmox.com Git - mirror_zfs.git/commitdiff
module/zfs: simplify ddt_stat_add() loop
authorAlexander <solbjorn@users.noreply.github.com>
Tue, 29 Jun 2021 14:26:11 +0000 (16:26 +0200)
committerGitHub <noreply@github.com>
Tue, 29 Jun 2021 14:26:11 +0000 (08:26 -0600)
LLVM's Polly (ISL to be precise) is unhappy with the loop from
ddt_stat_add():

  CC [M]  fs/zfs/zfs/ddt.o
../lib/External/isl/isl_schedule_node.c:2470: cannot insert node
between set or sequence node and its filter children

(building with the custom patch which adds Polly support to Kbuild)

The mentioned loop is rather suboptimal. All that we need is to just
treat ddt_stat_t as an array of u64 and perform 1:1 addition or
substraction. This can be done in simpler for-loop with the
determined index and bounds. Compiler will expand d_end - d into
a number of ddt_stat_t fields at compile time.
This prevents Polly from failing on this file.

Reviewed-by: Matthew Ahrens <mahrens@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Alexander Lobakin <alobakin@pm.me>
Closes #12253

module/zfs/ddt.c

index b94a9f54ece37a5479523cf37c1e03d482162c1d..7b0b1d8967616c8f35dd294c3cfe4c42c3652168 100644 (file)
@@ -423,8 +423,8 @@ ddt_stat_add(ddt_stat_t *dst, const ddt_stat_t *src, uint64_t neg)
 
        ASSERT(neg == 0 || neg == -1ULL);       /* add or subtract */
 
-       while (d < d_end)
-               *d++ += (*s++ ^ neg) - neg;
+       for (int i = 0; i < d_end - d; i++)
+               d[i] += (s[i] ^ neg) - neg;
 }
 
 static void