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