]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/CodeGen/AMDGPU/divergent-branch-uniform-condition.ll
Vendor import of llvm trunk r351319 (just before the release_80 branch
[FreeBSD/FreeBSD.git] / test / CodeGen / AMDGPU / divergent-branch-uniform-condition.ll
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
3
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.
8
9 target triple = "amdgcn-mesa-mesa3d"
10
11 define amdgpu_ps void @main(i32, float) {
12 ; CHECK-LABEL: main:
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_b64 s[4:5], 0
17 ; CHECK-NEXT:    v_interp_p1_f32_e32 v0, v1, attr0.x
18 ; CHECK-NEXT:    v_cmp_nlt_f32_e64 s[0:1], 0, v0
19 ; CHECK-NEXT:    v_mov_b32_e32 v1, 0
20 ; CHECK-NEXT:    ; implicit-def: $sgpr2_sgpr3
21 ; CHECK-NEXT:    ; implicit-def: $sgpr6_sgpr7
22 ; CHECK-NEXT:  BB0_1: ; %loop
23 ; CHECK-NEXT:    ; =>This Inner Loop Header: Depth=1
24 ; CHECK-NEXT:    v_cmp_gt_u32_e32 vcc, 32, v1
25 ; CHECK-NEXT:    s_and_b64 vcc, exec, vcc
26 ; CHECK-NEXT:    s_or_b64 s[6:7], s[6:7], exec
27 ; CHECK-NEXT:    s_or_b64 s[2:3], s[2:3], exec
28 ; CHECK-NEXT:    s_cbranch_vccz BB0_5
29 ; CHECK-NEXT:  ; %bb.2: ; %endif1
30 ; CHECK-NEXT:    ; in Loop: Header=BB0_1 Depth=1
31 ; CHECK-NEXT:    s_mov_b64 s[6:7], -1
32 ; CHECK-NEXT:    s_and_saveexec_b64 s[8:9], s[0:1]
33 ; CHECK-NEXT:    s_xor_b64 s[8:9], exec, s[8:9]
34 ; CHECK-NEXT:    ; mask branch BB0_4
35 ; CHECK-NEXT:  BB0_3: ; %endif2
36 ; CHECK-NEXT:    ; in Loop: Header=BB0_1 Depth=1
37 ; CHECK-NEXT:    v_add_u32_e32 v1, 1, v1
38 ; CHECK-NEXT:    s_xor_b64 s[6:7], exec, -1
39 ; CHECK-NEXT:  BB0_4: ; %Flow1
40 ; CHECK-NEXT:    ; in Loop: Header=BB0_1 Depth=1
41 ; CHECK-NEXT:    s_or_b64 exec, exec, s[8:9]
42 ; CHECK-NEXT:    s_andn2_b64 s[2:3], s[2:3], exec
43 ; CHECK-NEXT:    s_branch BB0_6
44 ; CHECK-NEXT:  BB0_5: ; in Loop: Header=BB0_1 Depth=1
45 ; CHECK-NEXT:    ; implicit-def: $vgpr1
46 ; CHECK-NEXT:  BB0_6: ; %Flow
47 ; CHECK-NEXT:    ; in Loop: Header=BB0_1 Depth=1
48 ; CHECK-NEXT:    s_and_b64 s[8:9], exec, s[6:7]
49 ; CHECK-NEXT:    s_or_b64 s[8:9], s[8:9], s[4:5]
50 ; CHECK-NEXT:    s_mov_b64 s[4:5], s[8:9]
51 ; CHECK-NEXT:    s_andn2_b64 exec, exec, s[8:9]
52 ; CHECK-NEXT:    s_cbranch_execnz BB0_1
53 ; CHECK-NEXT:  ; %bb.7: ; %Flow2
54 ; CHECK-NEXT:    s_or_b64 exec, exec, s[8:9]
55 ; CHECK-NEXT:    v_mov_b32_e32 v1, 0
56 ; this is the divergent branch with the condition not marked as divergent
57 ; CHECK-NEXT:    s_and_saveexec_b64 s[0:1], s[2:3]
58 ; CHECK-NEXT:    ; mask branch BB0_9
59 ; CHECK-NEXT:  BB0_8: ; %if1
60 ; CHECK-NEXT:    v_sqrt_f32_e32 v1, v0
61 ; CHECK-NEXT:  BB0_9: ; %endloop
62 ; CHECK-NEXT:    s_or_b64 exec, exec, s[0:1]
63 ; CHECK-NEXT:    exp mrt0 v1, v1, v1, v1 done vm
64 ; CHECK-NEXT:    s_endpgm
65 start:
66   %v0 = call float @llvm.amdgcn.interp.p1(float %1, i32 0, i32 0, i32 %0)
67   br label %loop
68
69 loop:
70   %v1 = phi i32 [ 0, %start ], [ %v5, %endif2 ]
71   %v2 = icmp ugt i32 %v1, 31
72   br i1 %v2, label %if1, label %endif1
73
74 if1:
75   %v3 = call float @llvm.sqrt.f32(float %v0)
76   br label %endloop
77
78 endif1:
79   %v4 = fcmp ogt float %v0, 0.000000e+00
80   br i1 %v4, label %endloop, label %endif2
81
82 endif2:
83   %v5 = add i32 %v1, 1
84   br label %loop
85
86 endloop:
87   %v6 = phi float [ %v3, %if1 ], [ 0.0, %endif1 ]
88   call void @llvm.amdgcn.exp.v4f32(i32 0, i32 15, float %v6, float %v6, float %v6, float %v6, i1 true, i1 true)
89   ret void
90 }
91
92 declare float @llvm.sqrt.f32(float) #1
93 declare float @llvm.amdgcn.interp.p1(float, i32, i32, i32) #1
94 declare void @llvm.amdgcn.exp.v4f32(i32, i32, float, float, float, float, i1, i1) #0
95
96 attributes #0 = { nounwind }
97 attributes #1 = { nounwind readnone }