llvm.org GIT mirror llvm / cb675e5
Merging r236306: ------------------------------------------------------------------------ r236306 | thomas.stellard | 2015-04-30 23:44:08 -0400 (Thu, 30 Apr 2015) | 11 lines R600/SI: Fix verifier errors from the SIAnnotateControlFlow pass This pass was generating 'Instruction does not dominate all uses!' errors for programs which had loops with a condition variable that depended on the result of a phi instruction from outside of the loop. The pass was inserting new phi nodes outside of the loop which used values defined inside the loop. http://bugs.freedesktop.org/show_bug.cgi?id=90056 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_36@236451 91177308-0d34-0410-b5e6-96231b3b80d8 Tom Stellard 4 years ago
2 changed file(s) with 47 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
208208 /// \brief Recursively handle the condition leading to a loop
209209 Value *SIAnnotateControlFlow::handleLoopCondition(Value *Cond, PHINode *Broken,
210210 llvm::Loop *L) {
211 if (PHINode *Phi = dyn_cast(Cond)) {
211
212 // Only search through PHI nodes which are inside the loop. If we try this
213 // with PHI nodes that are outside of the loop, we end up inserting new PHI
214 // nodes outside of the loop which depend on values defined inside the loop.
215 // This will break the module with
216 // 'Instruction does not dominate all users!' errors.
217 PHINode *Phi = nullptr;
218 if ((Phi = dyn_cast(Cond)) && L->contains(Phi)) {
219
212220 BasicBlock *Parent = Phi->getParent();
213221 PHINode *NewPhi = PHINode::Create(Int64, 0, "", &Parent->front());
214222 Value *Ret = NewPhi;
2222 ENDIF:
2323 br i1 %1, label %ENDLOOP, label %ENDIF
2424 }
25
26
27 ; FUNC-LABEL: {{^}}phi_cond_outside_loop:
28 ; FIXME: This could be folded into the s_or_b64 instruction
29 ; SI: s_mov_b64 [[ZERO:s\[[0-9]+:[0-9]+\]]], 0
30 ; SI: [[LOOP_LABEL:[A-Z0-9]+]]
31 ; SI: v_cmp_ne_i32_e64 [[COND:s\[[0-9]+:[0-9]+\]]], v{{[0-9]+}}, 0
32
33 ; SI_IF_BREAK instruction:
34 ; SI: s_or_b64 [[BREAK:s\[[0-9]+:[0-9]+\]]], [[COND]], [[ZERO]]
35
36 ; SI_LOOP instruction:
37 ; SI: s_andn2_b64 exec, exec, [[BREAK]]
38 ; SI: s_cbranch_execnz [[LOOP_LABEL]]
39 ; SI: s_endpgm
40
41 define void @phi_cond_outside_loop(i32 %a, i32 %b) {
42 entry:
43 %0 = icmp eq i32 %a , 0
44 br i1 %0, label %if, label %else
45
46 if:
47 br label %endif
48
49 else:
50 %1 = icmp eq i32 %b, 0
51 br label %endif
52
53 endif:
54 %2 = phi i1 [0, %if], [%1, %else]
55 br label %loop
56
57 loop:
58 br i1 %2, label %exit, label %loop
59
60 exit:
61 ret void
62 }