llvm.org GIT mirror llvm / 0113f5f
Merging r260692: ------------------------------------------------------------------------ r260692 | changpeng.fang | 2016-02-12 09:11:04 -0800 (Fri, 12 Feb 2016) | 13 lines AMDGPU/SI: Annotate Loops with Constant Condition in SIAnnotateControlFlow pass. Summary: It is possible that the loop condition can be a boolean constant (infinite loop, for example). So we sould handle constant condition in annotating a loop. This patch adds this functionality to support annotating constant condition. Reviewers: tstellarAMD, arsenm Subscribers: llvm-commits, arsenm Differential Revision: http://reviews.llvm.org/D15093 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_38@271685 91177308-0d34-0410-b5e6-96231b3b80d8 Tom Stellard 3 years ago
2 changed file(s) with 34 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
8080
8181 void insertElse(BranchInst *Term);
8282
83 Value *handleLoopCondition(Value *Cond, PHINode *Broken, llvm::Loop *L);
83 Value *handleLoopCondition(Value *Cond, PHINode *Broken,
84 llvm::Loop *L, BranchInst *Term);
8485
8586 void handleLoop(BranchInst *Term);
8687
212213
213214 /// \brief Recursively handle the condition leading to a loop
214215 Value *SIAnnotateControlFlow::handleLoopCondition(Value *Cond, PHINode *Broken,
215 llvm::Loop *L) {
216 llvm::Loop *L, BranchInst *Term) {
216217
217218 // Only search through PHI nodes which are inside the loop. If we try this
218219 // with PHI nodes that are outside of the loop, we end up inserting new PHI
236237 }
237238
238239 Phi->setIncomingValue(i, BoolFalse);
239 Value *PhiArg = handleLoopCondition(Incoming, Broken, L);
240 Value *PhiArg = handleLoopCondition(Incoming, Broken, L, Term);
240241 NewPhi->addIncoming(PhiArg, From);
241242 }
242243
275276 Value *Args[] = { Cond, Broken };
276277 return CallInst::Create(IfBreak, Args, "", Insert);
277278
279 // Insert IfBreak before TERM for constant COND.
280 } else if (isa(Cond)) {
281 Value *Args[] = { Cond, Broken };
282 return CallInst::Create(IfBreak, Args, "", Term);
283
278284 } else {
279285 llvm_unreachable("Unhandled loop condition!");
280286 }
290296
291297 Value *Cond = Term->getCondition();
292298 Term->setCondition(BoolTrue);
293 Value *Arg = handleLoopCondition(Cond, Broken, L);
299 Value *Arg = handleLoopCondition(Cond, Broken, L, Term);
294300
295301 for (pred_iterator PI = pred_begin(Target), PE = pred_end(Target);
296302 PI != PE; ++PI) {
0 ; RUN: llc -march=amdgcn -mcpu=kaveri < %s | FileCheck %s
1
2 ; CHECK-LABEL: {{^}}test:
3 ; CHECK s_and_saveexec_b64
4 ; CHECK s_xor_b64
5 ; CHECK s_or_b64 exec, exec
6 ; CHECK s_andn2_b64 exec, exec
7 ; CHECK s_cbranch_execnz
8 define spir_kernel void @test(i32 %arg, i32 %arg1, i32 addrspace(1)* nocapture %arg2, i32 %arg3, i32 %arg4, i32 %arg5, i32 %arg6) {
9 bb:
10 %tmp = icmp ne i32 %arg, 0
11 %tmp7 = icmp ne i32 %arg1, 0
12 %tmp8 = and i1 %tmp, %tmp7
13 br i1 %tmp8, label %bb9, label %bb11
14
15 bb9: ; preds = %bb
16 br label %bb10
17
18 bb10: ; preds = %bb10, %bb9
19 br label %bb10
20
21 bb11: ; preds = %bb
22 ret void
23 }