[LLVMdev] Simplifying boolean expressions

Chris Lattner sabre at nondot.org
Wed May 4 05:39:11 PDT 2005


On Wed, 4 May 2005, Vladimir Prus wrote:
> Suppose I have a code like this:
>
>       %tmp.aux = cast bool %tmp.24 to int
>        %tmp.x = xor int  %tmp.aux, 1                    ; negates tmp.24
>        %tmp.xx = cast int %tmp.x to bool
>        %tmp.y = or bool %tmp.xx, %tmp.24          ;  will be always true
>        br bool %tmp.y, label %next6, label %next7
>
> Is there an optimization in LLVM that will recognize that %tmp.y is always
> true, and replace the entire basic block with unconditional jump?
>
> I've tried running 'opt' on the attached file, but did not get the desired
> effect.
>
> The full story is that I'll be generating code like above, and while I
> probably can detect such redundant situation, I was hoping I can save myself
> some work, and just run LLVM optimizer at the produced code.

I will enhance the -instcombine pass to do this, hopefully today.

-Chris

-- 
http://nondot.org/sabre/
http://llvm.cs.uiuc.edu/




More information about the llvm-dev mailing list