LLVM unable to unroll loops [Can't unroll; loop not terminated by a conditional branch] -



getting error can't unroll; loop not terminated conditional branch following code:
for(i=0 ; j<10 && i<5 ; i++) j= j+2; using following command unrolling loops in file a.bc:
opt -loops -loop-rotate -loop-simplify -loop-unroll -unroll-count=3 -unroll-allow-partial -debug a.bc -o a.loop.bc
there way unroll loops avoiding error?

use command , should work (i have tested on llvm 3.6 , 3.7)

    opt -mem2reg  -simplifycfg  -loops  -lcssa -loop-simplify -loop-rotate    -loop-unroll -unroll-count=3 -unroll-allow-partial -debug a.bc -o a.loop.bc 

you need first of mem2reg have bitcode converted ssa (if not already), in other hand loop has 2 conditional exiting branches , 1 unconditional backedge, simplifycfg seems helpful transform one-conditional backedge form can handled unroll pass


Comments