[LLVMdev] Stupid '-load-vn -licm' question (LLVM 1.6)

Chris Lattner sabre at nondot.org
Thu Mar 16 17:47:16 PST 2006


On Thu, 16 Mar 2006, Eric Kidd wrote:

> Hello! I'm compiling code which uses pointers as iterators. For some 
> reason--probably a silly misunderstanding of the docs--I can't eliminate 
> duplicate pointer loads. I'll probably figure this out eventually, but if 
> somebody else sees the answer instantly, I certainly won't complain. :-)

There are no stupid questions.  Some are just easier to answer than others 
:)

> Here are the optimizers I'm running:
>
>  opt -f -simplifycfg -dce -instcombine -anders-aa -load-vn -licm -o 
> regex-opt.bc regex.bc
>
> The duplicate loads appear at the top of the %regex6 and %regex2 blocks 
> below. I've tried various alias analysis implementations either alone or in 
> combination.

LICM doesn't remove common subexpressions, also -load-vn doesn't affect 
LICM.  Try "-licm -load-vn -gcse" instead of "-load-vn -licm"

-Chris

> Any thoughts? I'm sure that this will prove embarrassingly obvious. :-)
>
> Cheers,
> Eric
>
> ; ModuleID = 'regex-opt.bc'
>
> implementation   ; Functions:
>
> bool %matches(ubyte* %begin, ubyte* %end) {
> entry:
>        %scan_end = getelementptr ubyte* %end, int -1           ; <ubyte*> 
> [#uses=1]
>        br label %loop_test
>
> regex6:         ; preds = %loop_test
>        %c8 = load ubyte* %iter         ; <ubyte> [#uses=1]
>        %matches9 = seteq ubyte %c8, 97         ; <bool> [#uses=1]
>        br bool %matches9, label %ret_true, label %regex2
>
> regex2:         ; preds = %regex6
>        %c = load ubyte* %iter          ; <ubyte> [#uses=1]
>        %matches = seteq ubyte %c, 98           ; <bool> [#uses=1]
>        br bool %matches, label %ret_true, label %loop_step
>
> loop_step:              ; preds = %regex2
>        %next = getelementptr ubyte* %iter, int 1               ; <ubyte*> 
> [#uses=1]
>        br label %loop_test
>
> loop_test:              ; preds = %loop_step, %entry
>        %iter = phi ubyte* [ %begin, %entry ], [ %next, %loop_step ] 
> ; <ubyte*> [#uses=4]
>        %done = setgt ubyte* %iter, %scan_end           ; <bool> [#uses=1]
>        br bool %done, label %ret_false, label %regex6
>
> ret_true:               ; preds = %regex2, %regex6
>        ret bool true
>
> ret_false:              ; preds = %loop_test
>        ret bool false
> }
>
> _______________________________________________
> 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