1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -march=amdgcn -mcpu=gfx900 -verify-machineinstrs < %s | FileCheck %s
4 ; This module creates a divergent branch. The branch is marked as divergent by
5 ; the divergence analysis but the condition is not. This test ensures that the
6 ; divergence of the branch is tested, not its condition, so that branch is
7 ; correctly emitted as divergent.
9 target triple = "amdgcn-mesa-mesa3d"
11 define amdgpu_ps void @main(i32, float) {
13 ; CHECK: ; %bb.0: ; %start
14 ; CHECK-NEXT: v_readfirstlane_b32 s0, v0
15 ; CHECK-NEXT: s_mov_b32 m0, s0
16 ; CHECK-NEXT: s_mov_b32 s0, 0
17 ; CHECK-NEXT: v_interp_p1_f32_e32 v0, v1, attr0.x
18 ; CHECK-NEXT: v_cmp_nlt_f32_e32 vcc, 0, v0
19 ; CHECK-NEXT: s_mov_b64 s[4:5], 0
20 ; CHECK-NEXT: ; implicit-def: $sgpr6_sgpr7
21 ; CHECK-NEXT: ; implicit-def: $sgpr2_sgpr3
22 ; CHECK-NEXT: s_branch BB0_3
23 ; CHECK-NEXT: BB0_1: ; %Flow1
24 ; CHECK-NEXT: ; in Loop: Header=BB0_3 Depth=1
25 ; CHECK-NEXT: s_or_b64 exec, exec, s[8:9]
26 ; CHECK-NEXT: s_mov_b64 s[10:11], 0
27 ; CHECK-NEXT: BB0_2: ; %Flow
28 ; CHECK-NEXT: ; in Loop: Header=BB0_3 Depth=1
29 ; CHECK-NEXT: s_and_b64 s[8:9], exec, s[6:7]
30 ; CHECK-NEXT: s_or_b64 s[8:9], s[8:9], s[4:5]
31 ; CHECK-NEXT: s_andn2_b64 s[2:3], s[2:3], exec
32 ; CHECK-NEXT: s_and_b64 s[4:5], s[10:11], exec
33 ; CHECK-NEXT: s_or_b64 s[2:3], s[2:3], s[4:5]
34 ; CHECK-NEXT: s_mov_b64 s[4:5], s[8:9]
35 ; CHECK-NEXT: s_andn2_b64 exec, exec, s[8:9]
36 ; CHECK-NEXT: s_cbranch_execz BB0_6
37 ; CHECK-NEXT: BB0_3: ; %loop
38 ; CHECK-NEXT: ; =>This Inner Loop Header: Depth=1
39 ; CHECK-NEXT: s_or_b64 s[6:7], s[6:7], exec
40 ; CHECK-NEXT: s_cmp_lt_u32 s0, 32
41 ; CHECK-NEXT: s_mov_b64 s[10:11], -1
42 ; CHECK-NEXT: s_cbranch_scc0 BB0_2
43 ; CHECK-NEXT: ; %bb.4: ; %endif1
44 ; CHECK-NEXT: ; in Loop: Header=BB0_3 Depth=1
45 ; CHECK-NEXT: s_mov_b64 s[6:7], -1
46 ; CHECK-NEXT: s_and_saveexec_b64 s[8:9], vcc
47 ; CHECK-NEXT: s_xor_b64 s[8:9], exec, s[8:9]
48 ; CHECK-NEXT: ; mask branch BB0_1
49 ; CHECK-NEXT: s_cbranch_execz BB0_1
50 ; CHECK-NEXT: BB0_5: ; %endif2
51 ; CHECK-NEXT: ; in Loop: Header=BB0_3 Depth=1
52 ; CHECK-NEXT: s_add_i32 s0, s0, 1
53 ; CHECK-NEXT: s_xor_b64 s[6:7], exec, -1
54 ; CHECK-NEXT: s_branch BB0_1
55 ; CHECK-NEXT: BB0_6: ; %Flow2
56 ; CHECK-NEXT: s_or_b64 exec, exec, s[8:9]
57 ; CHECK-NEXT: v_mov_b32_e32 v1, 0
58 ; CHECK-NEXT: s_and_saveexec_b64 s[0:1], s[2:3]
59 ; CHECK-NEXT: ; mask branch BB0_8
60 ; CHECK-NEXT: BB0_7: ; %if1
61 ; CHECK-NEXT: v_sqrt_f32_e32 v1, v0
62 ; CHECK-NEXT: BB0_8: ; %endloop
63 ; CHECK-NEXT: s_or_b64 exec, exec, s[0:1]
64 ; CHECK-NEXT: exp mrt0 v1, v1, v1, v1 done vm
65 ; CHECK-NEXT: s_endpgm
66 ; this is the divergent branch with the condition not marked as divergent
68 %v0 = call float @llvm.amdgcn.interp.p1(float %1, i32 0, i32 0, i32 %0)
72 %v1 = phi i32 [ 0, %start ], [ %v5, %endif2 ]
73 %v2 = icmp ugt i32 %v1, 31
74 br i1 %v2, label %if1, label %endif1
77 %v3 = call float @llvm.sqrt.f32(float %v0)
81 %v4 = fcmp ogt float %v0, 0.000000e+00
82 br i1 %v4, label %endloop, label %endif2
89 %v6 = phi float [ %v3, %if1 ], [ 0.0, %endif1 ]
90 call void @llvm.amdgcn.exp.v4f32(i32 0, i32 15, float %v6, float %v6, float %v6, float %v6, i1 true, i1 true)
94 declare float @llvm.sqrt.f32(float) #1
95 declare float @llvm.amdgcn.interp.p1(float, i32, i32, i32) #1
96 declare void @llvm.amdgcn.exp.v4f32(i32, i32, float, float, float, float, i1, i1) #0
98 attributes #0 = { nounwind }
99 attributes #1 = { nounwind readnone }