From 391bcf889391f9128763674087f2ddfd82671e90 Mon Sep 17 00:00:00 2001 From: Changpeng Fang Date: Thu, 17 May 2018 16:45:01 +0000 Subject: AMDGPU/SI: Handle infinite loop for the structurizer to work with CFG with infinite loops. Summary: The current StructurizeCFG pass only works for CFG with one exit. AMDGPUUnifyDivergentExitNodes combines multiple "return" blocks and/or "unreachable" blocks to one exit block for the Structurizer to work. However, infinite loop is another kind of special "exit", and if we don't handle it, the case of multiple exits will prevent the structurizer from working. In this work, for each infinite loop, we add a dummy edge to the "return" block, and thus the AMDGPUUnifyDivergentExitNodes pass will work with infinite loops. This will make CFG with infinite loops be structurized. Reviewer: nhaehnle Differential Revision: https://reviews.llvm.org/D46340 llvm-svn: 332625 --- llvm/test/CodeGen/AMDGPU/cf-loop-on-constant.ll | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'llvm/test/CodeGen/AMDGPU/cf-loop-on-constant.ll') diff --git a/llvm/test/CodeGen/AMDGPU/cf-loop-on-constant.ll b/llvm/test/CodeGen/AMDGPU/cf-loop-on-constant.ll index 1e04544d2cb..4872fbfadab 100644 --- a/llvm/test/CodeGen/AMDGPU/cf-loop-on-constant.ll +++ b/llvm/test/CodeGen/AMDGPU/cf-loop-on-constant.ll @@ -2,10 +2,11 @@ ; RUN: llc -march=amdgcn -verify-machineinstrs -O0 < %s ; GCN-LABEL: {{^}}test_loop: +; GCN: s_and_b64 vcc, exec, -1 ; GCN: [[LABEL:BB[0-9+]_[0-9]+]]: ; %for.body{{$}} ; GCN: ds_read_b32 ; GCN: ds_write_b32 -; GCN: s_branch [[LABEL]] +; GCN: s_cbranch_vccnz [[LABEL]] ; GCN: s_endpgm define amdgpu_kernel void @test_loop(float addrspace(3)* %ptr, i32 %n) nounwind { entry: -- cgit v1.2.3