[LLVMdev] Helping the optimizer along (__assume)

Paul Biggar paul.biggar at gmail.com
Thu Oct 23 05:12:04 PDT 2008

On Thu, Oct 23, 2008 at 8:23 AM, Duncan Sands <baldrick at free.fr> wrote:
>> >     %cond = i1 ...
>> >     br i1 %cond, label %always, label %never
>> > never:
>> >    call void @llvm.abort()
>> >     unreachable
>> >
>> > At codegen time @llvm.abort() can be lowered to
>> > nothing at all.  I'm not saying that this is my
>> > favorite solution, but it is simple.
>> How is this different than just branching to unreachable?  Branching
>> to unreachable says that "this condition is true or else the program
>> has undefined behavior".  This means that the condition must be true :)
> The difference is that simplifycfg will remove the branch
> to %never if %never only contains unreachable.  The role
> of the intrinsic call is to fool simplifycfg into not
> doing this!

This certainly sounds like the simplest approach, even though it adds
an intrinsic. Is there general interest in adding this?


Paul Biggar
paul.biggar at gmail.com

More information about the llvm-dev mailing list