我有以下情况:
A
/ \
B C
\ /
D
/ \
E F
\ /
...在A,B,C,D,E,F都是基本块的情况下,|是向下箭头。
现在,在B中,我将有一些def,比如%mul = ...,稍后将在相应的左侧块E中使用,比如... = %mul ...。我插入了适当的控制流--要么只接受左边的分支,要么只有右边的分支,问题是我在验证传递时得到了一个Instruction does not dominate all uses错误。
我试图通过添加PHINode指令来解决这个问题,如下所示:
B: ; preds = %A
%shl = shl ...
br label %D
C: ; preds = %A
...
br label %D
D: ; preds = %B , %C
...
br i1 %ctrl, label %E, label %F
E: ; preds = %D
%phi_nlcs = phi i32 [ %shl, %extra_l_diff ], [ 0, %for.cond ]
%cmp = icmp slt i32 %phi_nlcs, %1
br label ...省略号是为了隐藏不相关的细节,我也重命名了块,但是核心逻辑应该在那里。如您所见,我已经用适当的%shl调用替换了PHINode的使用。
但是,现在我得到了以下新错误:
PHINode should have one entry for each predecessor of its parent basic block!
%phi_nlcs = phi i32 [ %shl, %extra_l_diff ], [ 0, %for.cond ]我怎么才能解决这个问题?
发布于 2015-01-19 22:47:18
phi节点需要位于D的开头。
D:
%phi_nlcs = phi [%shl, B] [undef, C] ; if we've come from B use %shl, if from C an undef value.
...这是因为phi节点表示的是每个占主导地位的基本块(B和C)所需的值,因此它需要放置在基本块组合的边缘。
https://stackoverflow.com/questions/28034601
复制相似问题