On Wed, 26 Aug 2015 14:21:07 +0100 "Ben Avison" <[email protected]> wrote:
> I hadn't really investigated that, but having had a bit of a play with
> ARM GCC, I see that it fails to use the runtime function that returns
> both the quotient and remainder (__aeabi_idivmod) with the operations in
> macro form. I get more luck writing them as functions:
>
> inline int
> DIV (int a, int b)
> {
> int q = a / b;
> int r = a - q * b;
> return q - (r < 0);
> }
>
> inline int
> MOD (int a, int b)
> {
> int r = a % b;
> if (r < 0)
> r += b;
> return r;
> }
>
> with the caveat that these are based on the macros from my 2015-08-18
> post, which rely on b being positive. (Set aside for the moment whether
> an inline function with an all-caps name is a good idea...)
FWIW, when I looked at the macros (old and proposed), my head started
spinning. Looking at these inline functions, I feel I could actually
understand them without rewriting them.
- my 2c on readability
Not to mention that unlike the macros, these do not evaluate the
arguments multiple times.
Btw. I personally agree with Siarhei's testing argument. If there is
any uncertainty whether existing code is good or not, writing a test to
explicitly check for it is a nice way. If users come back reporting
test failures, then we have a problem. Otherwise no need to pay
attention.
I just wish testing for performance was as reliable as for
correctness...
Thanks,
pq
pgpllvIGY4CcZ.pgp
Description: OpenPGP digital signature
_______________________________________________ Pixman mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/pixman
