[LLVMdev] missed optimizations
Cédric Venet
cedric.venet at laposte.net
Thu Sep 4 09:19:46 PDT 2008
Nuno Lopes a écrit :
> Hi,
>
> I have two questions about optimizations performed by llvm.
>
> Consider these simple functions:
> int x(int b) { return b?4:6; }
> int y() { return x(0); }
>
> int x2() { return 5; }
> int y2() { return x2(); }
>
> the optimized bitcode (with clang + opt -std-compiler-opts) is:
> define i32 @y(...) nounwind {
> entry:
> ret i32 6
> }
>
> define i32 @y2(...) nounwind {
> entry:
> %call = call i32 (...)* @x2( ) ; <i32> [#uses=0]
> ret i32 5
> }
>
> So why does LLVM optimizes the more difficult case, but leaves behind the
> function call in the easiest case? :)
>
I don't know why vararg would inhibit optimisation but maybe it is the
problem.
You should try with:
int x2(void) { return 5; }
int y2(void) { return x2(); }
it may solve the problem (or use C++ as langage)
Cédric
More information about the llvm-dev
mailing list