[LLVMdev] Simplifying boolean expressions

Vladimir Prus ghost at cs.msu.su
Wed May 4 22:47:50 PDT 2005


On Wednesday 04 May 2005 18:34, Chris Lattner wrote:
> On Wed, 4 May 2005, Vladimir Prus wrote:
> >       %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?
>
> Actually, the -instcombine pass already does this.  Please try it out and
> let me know if it doesn't do what you want.

It does work! For some reason, I was assuming that running 'opt' without 
arguments would run some "reasonable" set of optimizations, while in reality, 
it does not run any.

Thanks,
Volodya




More information about the llvm-dev mailing list