[LLVMdev] Helping the optimizer along (__assume)
Duncan Sands
baldrick at free.fr
Wed Oct 22 22:45:26 PDT 2008
> Can't you implement __builtin_assume(cond) to codegen to something like:
>
> %cond = i1 ...
> br i1 %cond, label %always, label %never
> never:
> unreachable
> always:
The code generators will remove the branch to %never.
I already tried this :) What would work is to define
an llvm.abort intrinsic, and do:
%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.
Ciao,
Duncan.
More information about the llvm-dev
mailing list