]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
polyval: Remove precomputation for ctmul64 case.
authorNick Mathewson <nickm@torproject.org>
Sat, 26 Apr 2025 00:44:06 +0000 (20:44 -0400)
committerNick Mathewson <nickm@torproject.org>
Wed, 21 May 2025 13:43:51 +0000 (09:43 -0400)
In my benchmarks it saved less than 1%, so it really
doesn't make sense to keep it.

src/ext/polyval/ctmul64.c
src/ext/polyval/polyval.c
src/ext/polyval/polyval.h

index 1b10aa196f7b7c3a7e0274386c7d157c1be12205..c7fc1c3acd9839f125245f59ddc3cc75135f5968 100644 (file)
@@ -82,9 +82,8 @@ pv_mul_y_h(polyval_t *pv)
        y1 = pv->y.hi;
        h0 = pv->key.h.lo;
        h1 = pv->key.h.hi;
-       // TODO(nm) does it actually make sense for us to precompute this?
-       h0r = pv->key.hr.lo;
-       h1r = pv->key.hr.hi;
+       h0r = rev64(h0);
+       h1r = rev64(h1);
 
        h2 = h0 ^ h1;
        h2r = h0r ^ h1r;
index cc31a92be9f9ba945264b9b15ed0e554b81d89e6..9109f704790abaee57e6a56cbbc5c09f114b3085 100644 (file)
@@ -63,10 +63,6 @@ static inline void u128_to_bytes(u128, uint8_t *bytes_out);
  * (Within the polyval struct, perform "y ^= v").
  */
 static inline void pv_xor_y(polyval_t *, u128 v);
-/**
- * Initialize any derived fields in pv.
- */
-static inline void pv_init_extra(polyval_key_t *pv);
 
 /* ========
  * The function which we expect our backend to implement.
@@ -139,11 +135,6 @@ pv_xor_y(polyval_t *pv, u128 v)
 {
   pv->y = _mm_xor_si128(pv->y, v);
 }
-static inline void
-pv_init_extra(polyval_key_t *pv)
-{
-  (void)pv;
-}
 #elif defined(PV_USE_CTMUL64)
 
 #include "ext/polyval/ctmul64.c"
@@ -172,12 +163,6 @@ pv_xor_y(polyval_t *pv, u128 val)
   pv->y.lo ^= val.lo;
   pv->y.hi ^= val.hi;
 }
-static inline void
-pv_init_extra(polyval_key_t *pv)
-{
-  pv->hr.lo = rev64(pv->h.lo);
-  pv->hr.hi = rev64(pv->h.hi);
-}
 #elif defined(PV_USE_CTMUL)
 #include "ext/polyval/ctmul.c"
 
@@ -207,18 +192,12 @@ pv_xor_y(polyval_t *pv, u128 val)
     pv->y.v[i] ^= val.v[i];
   }
 }
-static inline void
-pv_init_extra(polyval_key_t *pv)
-{
-  (void)pv;
-}
 #endif
 
 void
 polyval_key_init(polyval_key_t *pvk, const uint8_t *key)
 {
   pvk->h = u128_from_bytes(key);
-  pv_init_extra(pvk);
 }
 void
 polyval_init(polyval_t *pv, const uint8_t *key)
index 5bfaae1e884b6dc7b79d241dc89f3c221d5e90cb..a0e71e81bd328c38663a48279462b1444aca888a 100644 (file)
@@ -57,11 +57,6 @@ typedef struct pv_u128_ {
 /** A key for a polyval hash, plus any precomputed key material. */
 typedef struct polyval_key_t {
   pv_u128_ h;
-#ifdef PV_USE_CTMUL64
-  /** The elements of the key in bit-reversed form.
-   * (Used as an optimization.) */
-  pv_u128_ hr;
-#endif
 } polyval_key_t;
 
 /**