[LLVMdev] is this code really JITed and/or optimized ? ..

Chris Lattner sabre at nondot.org
Fri Aug 13 15:31:58 PDT 2004


On Sat, 14 Aug 2004, Valery A.Khamenya wrote:

> (thanks to Reid, who gave nice advice) the fibonacci function code
> works now. Please find attached file.
>
> but... the performance is adequate, say, for byte-code
> interpretation mode and not for optimized JITing.
> fibonacci function of 35 from attached file is more
> then 100 times slower then the following code compiled
> with "gcc -O2" :
> -----------
> #include <iostream>
> int fib(int x) {
> if(x<=2) return 1;
> return fib(x-1)+fib(x-2);
> }
>
> int main(int argc, char**argv) {
>   int n = argc > 1 ? atol(argv[1]) : 10;
>   std::cout << fib(n) << "\n";
> }
> -----------
>
> Where's the rake I step at?..
>
> I guess the JIT was not really invoked or code was not optimized..

If it's that slow, you're probably getting the interpreter instead of the
JIT.  Try adding -print-machineinstr to the command line, or -debug, and
see what happens.  If you're not getting the JIT, try stepping through the
LLVM program to see where it makes the execution engine and decides which
one to use...

-Chris

-- 
http://llvm.cs.uiuc.edu/
http://nondot.org/sabre/




More information about the llvm-dev mailing list