[LLVMdev] optimization question

Chris Lattner sabre at nondot.org
Mon Dec 5 22:02:58 PST 2005


On Mon, 5 Dec 2005, Umar Janjua wrote:

>
> I tried to optimize the following code using opt -load-vn -sccp -dcse, but no
> effect. The loading and storing of unique should be removed, and branch should
> be statically evaluated.

Without a testable testcase, it's hard to say, however -load-vn -gcse 
should do it, allowing -instcombine -simplifycfg to constant prop and nuke 
the branch.

-Chris

> The code:
>
> %tmp.0 = call int %acquireLock( ) ; <int> [#uses=0]
> store int 1, int* %unique
> %load = load int* %unique ; <int> [#uses=1]
> %Set = seteq int 1, %load ; <bool> [#uses=1]
> br bool %Set, label %Insertion, label %remaining
>
> Insertion: ; preds = %entry
>            call int %releaseLock( ) ; <int>:0 [#uses=0]
>            br label %remaining
>
> remaining: ; preds = %Insertion, %entry
> %tmp.1 = call int %acquireLock( ) ; <int> [#uses=0]
> %tmp.2 = call int %releaseLock( )
>
> Note:
>
> %unique = internal global int 0		; <int*> [#uses=2]
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>

-Chris

-- 
http://nondot.org/sabre/
http://llvm.org/




More information about the llvm-dev mailing list