[LLVMdev] precondition suggestion to LLVM

David Blaikie dblaikie at gmail.com
Mon Oct 22 21:40:40 PDT 2012


On Mon, Oct 22, 2012 at 9:33 PM, Niko Zarzani <koni10 at hotmail.it> wrote:
> Thank you, it was what I really was searching for :)
>
> However, I don't know if I well understood. I've find this link in the
> second link which seemed what i was looking for:
> http://nondot.org/sabre/LLVMNotes/BuiltinUnreachable.txt .
> If I put around the code block (inside my function with precondition (x>0 &&
> y>0)) a contruct like that that use __builtin_unreachable:
>
> int foo(int x, int y){
>
>    if(x>0 && y>0){
>        ...function codeblock...
>    }
>    {
>       __builtin_unreachable ();
>    }
>
> }
>
> I can get the optimization without really having a branch jump in the
> machine code?

In theory, yes - in practice, we eliminate unreachable blocks too
early for any real optimization to occur on the basis of this branch
to unreachable. More details here:
http://llvm.org/bugs/show_bug.cgi?id=810

> Thank you again,
>
> Niko Zarzani
>
>> Date: Mon, 22 Oct 2012 23:41:43 -0400
>> From: xi.wang at gmail.com
>> To: koni10 at hotmail.it
>> CC: llvmdev at cs.uiuc.edu
>
>> Subject: Re: [LLVMdev] precondition suggestion to LLVM
>>
>> You may want to check this out:
>>
>> http://lists.cs.uiuc.edu/pipermail/llvmdev/2012-October/053924.html
>>
>> and also
>>
>> http://llvm.org/PR810
>>
>> - xi
>>
>> On 10/22/12 6:05 PM, Niko Zarzani wrote:
>> > Hi all,
>> > Is there any way to tell LLVM some additional information about the
>> > variables in the code in order to make better optimization?
>> > For example, if my function has a certain precondition (such as x>0)
>> > then it will be possible to better optimize the code given that
>> > information (which the compiler does not know).
>> > I am new in this field and I don't know if there are ways to tell the
>> > compiler preconditions (such as by using some preprocessing directives).
>> > Thank you in advance,
>> > Niko Zarzani
>
> _______________________________________________
> 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