[LLVMdev] How to disbale loop-rotate in opt -O3 ?

Jimborean Alexandra xinfinity_a at yahoo.com
Mon Aug 19 02:48:48 PDT 2013


Hello,

I am trying to simplify the CFG of a given code and eliminate the conditionals, even though I will obtain codes that are not semantically equivalent. 

For example, given a simple loop:

for(i=0; i<N; i++){
   a[i] = i;
    if (i%2==0)
      a[i] += 12;

}

I would keep only the loop, without the if statement:

for(i=0; i<N; i++){
   a[i] = i;
}

I can eliminate such conditionals on simple codes, however, the problem arises when optimization passes such as loop-rotate embed the original loop in a conditional. In this case, I want to keep the loop, but distinguish it from other loops that were embedded in conditionals in the original source code (the latter should still be eliminated).

Since I found no clues on how distinguish such loops, I tried to disable loop-rotate. For this purpose, I got the list of passes executed by O3, I eliminate loop-rotate and I call the reduced list of passes from opt: 


opt -targetdata -no-aa -tbaa -targetlibinfo -basicaa -preverify -domtree -verify -simplifycfg -domtree -scalarrepl -early-cse -lower-expect -targetlibinfo -targetdata -no-aa -tbaa -basicaa -globalopt -ipsccp -deadargelim -instcombine -simplifycfg -basiccg -prune-eh -inline -functionattrs -argpromotion -scalarrepl-ssa -domtree -early-cse -simplify-libcalls -lazy-value-info -jump-threading -correlated-propagation -simplifycfg -instcombine -tailcallelim -simplifycfg -reassociate -domtree -loops -loop-simplify -lcssa -loop-rotate -licm -lcssa -loop-unswitch -instcombine -scalar-evolution -loop-simplify -lcssa -indvars -loop-idiom -loop-deletion -loop-unroll -memdep -gvn -memdep -memcpyopt -sccp -instcombine -lazy-value-info -jump-threading -correlated-propagation -domtree -memdep -dse -adce -simplifycfg -instcombine -strip-dead-prototypes -globaldce -constmerge -preverify -domtree -verify file.ll
However, I am not successful in calling the passes in this form, as I already get an error on the first pass: 
LLVM ERROR: Bad TargetData ctor used.  Tool did not specify a TargetData to use?

Any advice on how can I either:
(i) disable loop rotation
(ii) inhibit embedding the loop in a conditional
(iii) distinguish rotated loops from other loops originally embedded in conditionals in the source code
(iv) run the list of optimization passes by hand (specify the TargetData)   ?

Any help is appreciated.

Thank you,
Alexandra
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130819/8a04247d/attachment.html>


More information about the llvm-dev mailing list