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

拟墨画扇 提交于 2019-12-01 12:39:17

问题



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


回答1:


use this command and it should work (I have tested it on LLVM 3.6 and 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 all mem2reg to have your bitcode converted to SSA from (if it is not already), in the other hand the loop has two conditional exiting branches and one unconditional backedge, so simplifycfg seems helpful to transform it to one-conditional backedge form which can be handled by unroll pass



来源:https://stackoverflow.com/questions/31340251/llvm-unable-to-unroll-loops-cant-unroll-loop-not-terminated-by-a-conditional

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!