[LLVMdev] optimization question

Umar Janjua Umar.Janjua at cl.cam.ac.uk
Mon Dec 5 08:11:33 PST 2005

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.
Any suggestions?

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( )


%unique = internal global int 0		; <int*> [#uses=2]

More information about the llvm-dev mailing list