xref: /aosp_15_r20/external/llvm/test/CodeGen/AMDGPU/endcf-loop-header.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -march=amdgcn -mcpu=SI -verify-machineinstrs | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker
3*9880d681SAndroid Build Coastguard Worker; This tests that the llvm.SI.end.cf intrinsic is not inserted into the
4*9880d681SAndroid Build Coastguard Worker; loop block.  This intrinsic will be lowered to s_or_b64 by the code
5*9880d681SAndroid Build Coastguard Worker; generator.
6*9880d681SAndroid Build Coastguard Worker
7*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: {{^}}test:
8*9880d681SAndroid Build Coastguard Worker
9*9880d681SAndroid Build Coastguard Worker; This is was lowered from the llvm.SI.end.cf intrinsic:
10*9880d681SAndroid Build Coastguard Worker; CHECK: s_or_b64 exec, exec
11*9880d681SAndroid Build Coastguard Worker
12*9880d681SAndroid Build Coastguard Worker; CHECK: [[LOOP_LABEL:[0-9A-Za-z_]+]]: ; %loop{{$}}
13*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: s_or_b64 exec, exec
14*9880d681SAndroid Build Coastguard Worker; CHECK: s_cbranch_execnz [[LOOP_LABEL]]
15*9880d681SAndroid Build Coastguard Workerdefine void @test(i32 addrspace(1)* %out) {
16*9880d681SAndroid Build Coastguard Workerentry:
17*9880d681SAndroid Build Coastguard Worker  %cond = call i32 @llvm.r600.read.tidig.x() #0
18*9880d681SAndroid Build Coastguard Worker  %tmp0 = icmp eq i32 %cond, 0
19*9880d681SAndroid Build Coastguard Worker  br i1 %tmp0, label %if, label %loop
20*9880d681SAndroid Build Coastguard Worker
21*9880d681SAndroid Build Coastguard Workerif:
22*9880d681SAndroid Build Coastguard Worker  store i32 0, i32 addrspace(1)* %out
23*9880d681SAndroid Build Coastguard Worker  br label %loop
24*9880d681SAndroid Build Coastguard Worker
25*9880d681SAndroid Build Coastguard Workerloop:
26*9880d681SAndroid Build Coastguard Worker  %tmp1 = phi i32 [0, %entry], [0, %if], [%inc, %loop]
27*9880d681SAndroid Build Coastguard Worker  %inc = add i32 %tmp1, %cond
28*9880d681SAndroid Build Coastguard Worker  %tmp2 = icmp ugt i32 %inc, 10
29*9880d681SAndroid Build Coastguard Worker  br i1 %tmp2, label %done, label %loop
30*9880d681SAndroid Build Coastguard Worker
31*9880d681SAndroid Build Coastguard Workerdone:
32*9880d681SAndroid Build Coastguard Worker  %tmp3 = getelementptr i32, i32 addrspace(1)* %out, i64 1
33*9880d681SAndroid Build Coastguard Worker  store i32 %inc, i32 addrspace(1)* %tmp3
34*9880d681SAndroid Build Coastguard Worker  ret void
35*9880d681SAndroid Build Coastguard Worker}
36*9880d681SAndroid Build Coastguard Worker
37*9880d681SAndroid Build Coastguard Workerdeclare i32 @llvm.r600.read.tidig.x() #0
38*9880d681SAndroid Build Coastguard Worker
39*9880d681SAndroid Build Coastguard Workerattributes #0 = { readnone }
40