[Mono-dev] JIT register binding

Konrad M. Kruczyński konrad.kruczynski at gmail.com
Sat May 21 05:44:35 EDT 2011


Hi Miguel,

> Could you try the same code, but using LLVM as the code generation
> engine?

As expected, llvm generation is as optimal, as can be seen:
 movsd  0x8(%ebx),%xmm4
 movsd  0x8(%edi),%xmm1
 subsd  %xmm1,%xmm4
 movaps %xmm4,%xmm1
 mulsd  %xmm1,%xmm1
 movsd  0x10(%ebx),%xmm2
 movsd  0x10(%edi),%xmm3
 subsd  %xmm3,%xmm2
 movaps %xmm2,%xmm3
 mulsd  %xmm3,%xmm3
 addsd  %xmm1,%xmm3
 movsd  0x18(%ebx),%xmm1
 movsd  0x18(%edi),%xmm5
 subsd  %xmm5,%xmm1
 movaps %xmm1,%xmm5
 mulsd  %xmm5,%xmm5
 addsd  %xmm3,%xmm5
No store operations and pointless data moves between register. I am
not sure what technique is used by llvm, but probably some kind of
graph coloring with foregoing register coalescing.

> But I do agree that it would be nice to fix it in the regular case.

I think there are two problems here. One is that using llvm causes
some cpu and memory overhead during compilation, so overall
application performance can be lower. The other one is that using llvm
is nonstandard: some people know that it can be used, however it is
not as easy, because it does not come in package (maybe some USE flags
can be used at gentoo). For instance, folks at alioth debian shootout
aren't using llvm with mono; these tests are mainly computational and
mono results are suboptimal. If somebody just glances at the result,
he won't probably wonder whether there are some options to improve
performance, such as llvm, or not.

Some time ago I came across an article about generation time optimized
version of graph coloring algorithm, used by llvm in their jit mode.
Maybe some kind of that should be implemented. What algorithm is used
currently? As I can tell by file name, it is probably linear scan, but
there are couple versions of linear scan and one can find a couple of
FIXMEs in the implementation so I don't know how complete is it.

Btw, as I understood from the article, llvm has a special jit mode,
where only low cost optimizations are used. Is that what mono is
using?

-- 
Regards,
 Konrad



More information about the Mono-devel-list mailing list