Yuri
2010-Apr-29 08:44 UTC
[LLVMdev] Why the same code is much slower in JIT compared to separate executable?
I run the same simple Fibonacci computing code in JIT and as a native executable. I see that with argument 45 JIT runs for 11.3sec and executable runs for 7.5sec. Why there is such difference? Yuri -------- fib.ll -------- ; ModuleID = 'all.bc' @.str = private constant [12 x i8] c"fib(%i)=%i\0A\00", align 1 ; <[12 x i8]*> [#uses=1] define i32 @fib(i32 %AnArg) { EntryBlock: %cond = icmp sle i32 %AnArg, 2 ; <i1> [#uses=1] br i1 %cond, label %return, label %recurse return: ; preds = %EntryBlock ret i32 1 recurse: ; preds = %EntryBlock %arg = sub i32 %AnArg, 1 ; <i32> [#uses=1] %fibx1 = tail call i32 @fib(i32 %arg) ; <i32> [#uses=1] %arg1 = sub i32 %AnArg, 2 ; <i32> [#uses=1] %fibx2 = tail call i32 @fib(i32 %arg1) ; <i32> [#uses=1] %addresult = add i32 %fibx1, %fibx2 ; <i32> [#uses=1] ret i32 %addresult } define i32 @main(i32 %argc, i8** nocapture %argv) nounwind { entry: %0 = getelementptr inbounds i8** %argv, i32 1 ; <i8**> [#uses=1] %1 = load i8** %0, align 4 ; <i8*> [#uses=1] %2 = tail call i32 @atoi(i8* %1) nounwind ; <i32> [#uses=2] %3 = tail call i32 @fib(i32 %2) nounwind ; <i32> [#uses=1] %4 = tail call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([12 x i8]* @.str, i32 0, i32 0), i32 %2, i32 %3) nounwind ; <i32> [#uses=0] ret i32 undef } declare i32 @atoi(i8* nocapture) nounwind readonly declare i32 @printf(i8* nocapture, ...) nounwind -------- run-jit shell script -------- llvm-as fib.ll && \ time lli -O3 fib.bc 45 -------- run-exe shell script -------- llvm-as fib.ll && \ llc -O3 fib.bc -o fib.s && \ as fib.s -o fib.o && \ gcc -o fib fib.o && \ time fib 45
Török Edwin
2010-Apr-29 08:49 UTC
[LLVMdev] Why the same code is much slower in JIT compared to separate executable?
On 04/29/2010 11:44 AM, Yuri wrote:> > I run the same simple Fibonacci computing code in JIT and as a native > executable. I see that with argument 45 JIT runs for 11.3sec and > executable runs for 7.5sec. > Why there is such difference?How long does it take for llc to compile it? Remember that the JIT includes code generation time. Best regards, --Edwin
Yuri
2010-Apr-29 09:13 UTC
[LLVMdev] Why the same code is much slower in JIT compared to separate executable?
Török Edwin wrote:> How long does it take for llc to compile it? > Remember that the JIT includes code generation timellc takes almost no time (0.00 user as measured by time), code is tiny. Yuri
Reasonably Related Threads
- [LLVMdev] Why the same code is much slower in JIT compared to separate executable?
- [LLVMdev] Why the same code is much slower in JIT compared to separate executable?
- [LLVMdev] Why the same code is much slower in JIT compared to separate executable?
- [LLVMdev] Why the same code is much slower in JIT compared to separate executable?
- [LLVMdev] Why the same code is much slower in JIT compared to separate executable?