[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Faster tagged integer arithmetic
From: |
Ludovic Courtès |
Subject: |
Re: Faster tagged integer arithmetic |
Date: |
Fri, 19 Nov 2010 15:28:15 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) |
Hi!
There’s now an x86_64-optimized version of fixnum addition and
subtraction, which provide a 17% speedup according to the
micro-benchmarks in ‘arithmetic.bm’.
I’ve tried something similar for multiplication, but that yielded only
5% (which is sort of expected, since the code is very close to what the
naive C code does), so I decided not to include it. Here’s the code,
for posterity:
# define ASM_MUL(x, y) \
{ \
asm volatile goto ("mov %1, %%rcx; mov %0, %%rbx; " \
"test %[tag], %%cl; je %l[slow_mul]; " \
"test %[tag], %%bl; je %l[slow_mul]; " \
"sar %[tag_size], %%rcx; " \
"sub %[tag], %%rbx; " \
"imul %%rbx, %%rcx; jo %l[slow_mul]; " \
"add %[tag], %%rcx; " \
"mov %%rcx, (%[vsp])\n" \
: /* no outputs */ \
: "r" (x), "r" (y), \
[vsp] "r" (sp), [tag] "i" (scm_tc2_int), \
[tag_size] "i" (2) \
: "rcx", "rbx", "memory" \
: slow_mul); \
NEXT; \
} \
slow_mul: \
do { } while (0)
Comments welcome!
Thanks,
Ludo’.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: Faster tagged integer arithmetic,
Ludovic Courtès <=