File: branch-outside.ll

package info (click to toggle)
llvm-toolchain-19 1%3A19.1.7-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,998,520 kB
  • sloc: cpp: 6,951,680; ansic: 1,486,157; asm: 913,598; python: 232,024; f90: 80,126; objc: 75,281; lisp: 37,276; pascal: 16,990; sh: 10,009; ml: 5,058; perl: 4,724; awk: 3,523; makefile: 3,167; javascript: 2,504; xml: 892; fortran: 664; cs: 573
file content (119 lines) | stat: -rw-r--r-- 2,627 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
; RUN: opt %s -mtriple amdgcn-- -passes='print<uniformity>' -disable-output 2>&1 | FileCheck %s

; CHECK=LABEL: UniformityInfo for function 'basic':
; CHECK: CYCLES ASSSUMED DIVERGENT:
; CHECK:   depth=1: entries(P T) Q
define amdgpu_kernel void @basic(i32 %a, i32 %b, i32 %c) {
entry:
 %cond.uni = icmp slt i32 %a, 0
 %tid = call i32 @llvm.amdgcn.workitem.id.x()
 %cond.div = icmp slt i32 %tid, 0
 br i1 %cond.div, label %T, label %P

P:
; CHECK:   DIVERGENT:   %pp.phi =
; CHECK: DIVERGENT:      %pp =
  %pp.phi  = phi i32 [ %a, %entry], [ %b, %T ]
  %pp = add i32 %b, 1
  br label %Q

Q:
; CHECK: DIVERGENT:   %qq =
; CHECK:   DIVERGENT:   %qq.div =
  %qq = add i32 %b, 1
  %qq.div = add i32 %pp.phi, 1
  br i1 %cond.uni, label %T, label %exit

T:
; CHECK:   DIVERGENT:   %t.phi =
; CHECK: DIVERGENT:     %tt =
  %t.phi = phi i32 [ %qq, %Q ], [ %a, %entry ]
  %tt = add i32 %b, 1
  br label %P

exit:
; CHECK-NOT: DIVERGENT:     %ee =
  %ee = add i32 %b, 1
  ret void
}

; CHECK=LABEL: UniformityInfo for function 'nested':
; CHECK: CYCLES ASSSUMED DIVERGENT:
; CHECK:  depth=1: entries(P T) Q A C B
define amdgpu_kernel void @nested(i32 %a, i32 %b, i32 %c) {
entry:
 %cond.uni = icmp slt i32 %a, 0
 %tid = call i32 @llvm.amdgcn.workitem.id.x()
 %cond.div = icmp slt i32 %tid, 0
 br i1 %cond.div, label %T, label %P

P:
 %pp.phi  = phi i32 [ %a, %entry], [ %b, %T ]
 %pp = add i32 %b, 1
 br i1 %cond.uni, label %B, label %Q

Q:
  %qq = add i32 %b, 1
  br i1 %cond.uni, label %T, label %exit

A:
  %aa = add i32 %b, 1
  br label %B

B:
  %bb = add i32 %b, 1
  br label %C

C:
  %cc = add i32 %b, 1
  br i1 %cond.uni, label %Q, label %A

T:
  %t.phi = phi i32 [ %qq, %Q ], [ %a, %entry ]
  %tt = add i32 %b, 1
  br i1 %cond.uni, label %A, label %P

exit:
  %ee = add i32 %b, 1
  ret void
}

; Just make sure that this does not asert. It is important that Q is recognized
; as the header of the outermost cycle. The incorrect assert was exercised by
; this hierarchy:
;
; CycleInfo for function: irreducible_outer_cycle
;    depth=1: entries(Q R) C B D
;        depth=2: entries(R) C B D
;            depth=3: entries(B) D
;
; CHECK-LABEL: UniformityInfo for function 'irreducible_outer_cycle':
; CHECK: CYCLES ASSSUMED DIVERGENT:
; CHECK:  depth=1: entries(Q R) C B D
define void @irreducible_outer_cycle(i1 %c1, i1 %c2, i1 %c3) {
entry:
  br i1 %c1, label %P, label %Q

P:
  br i1 false, label %Q, label %R

Q:
  br label %R

R:
  br i1 false, label %Q, label %B

B:
  br i1 false, label %C, label %D

D:
  br label %B

C:
  br i1 false, label %R, label %exit

exit:
  ret void
}

declare i32 @llvm.amdgcn.workitem.id.x() #0