diff options
| author | Mattias Andrée <maandree@kth.se> | 2016-05-04 14:33:27 +0200 |
|---|---|---|
| committer | Mattias Andrée <maandree@kth.se> | 2016-05-04 14:33:27 +0200 |
| commit | 1f8023e18a6dc7b950826810b392fdd46bcb0d45 (patch) | |
| tree | 4e6d0de20ef8f1dd52e4bc6e3a5b16813728b674 /src/internals.h | |
| parent | Fix indent (diff) | |
| download | libzahl-1f8023e18a6dc7b950826810b392fdd46bcb0d45.tar.gz libzahl-1f8023e18a6dc7b950826810b392fdd46bcb0d45.tar.bz2 libzahl-1f8023e18a6dc7b950826810b392fdd46bcb0d45.tar.xz | |
Optimise zand, zor, and zxor
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'src/internals.h')
| -rw-r--r-- | src/internals.h | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/internals.h b/src/internals.h index 841346f..f1a2f78 100644 --- a/src/internals.h +++ b/src/internals.h @@ -343,3 +343,31 @@ zfree_temp(z_t a) } /* } */ + +#define ZMEM_OP(a, b, c, n, OP) \ + do { \ + zahl_char_t *a__ = (a); \ + const zahl_char_t *b__ = (b); \ + const zahl_char_t *c__ = (c); \ + size_t i__, n__ = (n); \ + if (n__ <= 4) { \ + if (n__ >= 1) \ + a__[0] = b__[0] OP c__[0]; \ + if (n__ >= 2) \ + a__[1] = b__[1] OP c__[1]; \ + if (n__ >= 3) \ + a__[2] = b__[2] OP c__[2]; \ + if (n__ >= 4) \ + a__[3] = b__[3] OP c__[3]; \ + } else { \ + for (i__ = 0; (i__ += 4) < n__;) { \ + a__[i__ - 1] = b__[i__ - 1] OP c__[i__ - 1]; \ + a__[i__ - 2] = b__[i__ - 2] OP c__[i__ - 2]; \ + a__[i__ - 3] = b__[i__ - 3] OP c__[i__ - 3]; \ + a__[i__ - 4] = b__[i__ - 4] OP c__[i__ - 4]; \ + } \ + if (i__ > n__) \ + for (i__ -= 4; i__ < n__; i__++) \ + a__[i__] = b__[i__] OP c__[i__]; \ + } \ + } while (0) |
