LLVM无法展开循环.循环未由条件分支终止] [英] LLVM unable to unroll loops [Can't unroll; loop not terminated by a conditional branch]

查看:232
本文介绍了LLVM无法展开循环.循环未由条件分支终止]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我收到以下代码的错误Can't unroll; loop not terminated by a conditional branch:
for(i=0 ; j<10 && i<5 ; i++) j= j+2; 我正在使用以下命令来展开文件a.bc中的循环:
opt -loops -loop-rotate -loop-simplify -loop-unroll -unroll-count=3 -unroll-allow-partial -debug a.bc -o a.loop.bc
有没有一种方法可以避免出现此错误而展开循环?


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?

推荐答案

使用此命令,它应该可以工作(我已经在LLVM 3.6和3.7上对其进行了测试)

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

首先,您需要 mem2reg 将您的位代码从中转换为SSA(如果尚未转换),另一方面,循环中有两个条件退出分支和一个无条件的后端,因此 simplifycfg 似乎很有帮助,可以将其转换为可以通过展开通行证处理的一条件的后端

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

这篇关于LLVM无法展开循环.循环未由条件分支终止]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆