|
Message-ID: <alpine.LNX.2.11.1506281133060.20522@monopod.intra.ispras.ru>
Date: Sun, 28 Jun 2015 11:59:36 +0300 (MSK)
From: Alexander Monakov <amonakov@...ras.ru>
To: musl@...ts.openwall.com
Subject: Re: [PATCH v2 4/6] dynlink.c: pass gnu-hash table pointer to
gnu_lookup
(this and the previous email are actually following up on patch 5, not 4)
How about handling power-of-two divisors like this.
In precompute_udiv:
1. Factor out powers of two from 'div' up front and get rid of 'goto again'
(ok since doing the pre-shift unconditionally looks better)
2. If 'div' is now 1:
- on 64-bit there's no problem: set 'mul' to 1 and 's2' to 0
- on 32-bit: set 'mul' to 0
...and in umod:
3. On 32-bit arches, check 'mul' after pre-shift and skip to end if zero.
With this change it's easy to drop 'div' argument from 'umod', rename 'umod'
to 'udiv' and make the caller do the modulus computation.
Attaching a variant of the latency bench that implements the above; I also
tried to avoid small 'val' in the bench loop by using a recurrence with a
bitwise inversion.
Alexander
View attachment "umod-bench.c" of type "TEXT/x-c" (2338 bytes)
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.