[LLVMdev] missed optimizations

OvermindDL1 overminddl1 at gmail.com
Thu Sep 4 16:43:48 PDT 2008


The LLVM browser test optimizes both examples as expected...  What
optimization options are different?  Although that optimization could
be gcc-llvm level and not actual llvm level...

On Thu, Sep 4, 2008 at 10:19 AM, Cédric Venet <cedric.venet at laposte.net> wrote:
> 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
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>




More information about the llvm-dev mailing list