File: unstructured-branch.ll

package info (click to toggle)
llvm-toolchain-21 1%3A21.1.6-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,245,028 kB
  • sloc: cpp: 7,619,726; ansic: 1,434,018; asm: 1,058,748; python: 252,740; f90: 94,671; objc: 70,685; lisp: 42,813; pascal: 18,401; sh: 8,601; ml: 5,111; perl: 4,720; makefile: 3,675; awk: 3,523; javascript: 2,409; xml: 892; fortran: 770
file content (87 lines) | stat: -rw-r--r-- 1,857 bytes parent folder | download | duplicates (3)
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
; RUN: opt -mtriple amdgcn-- -passes='print<uniformity>' -disable-output %s 2>&1 | FileCheck %s

;             Alpha (div.uni)
;              |   \
;             Entry \
;          (div.cond)\
;             /   \   \
;            B0   B3  |
;            |    |   |
;            B1   B4<-+
;            |    |
;            B2   B5
;          /  |    |
;         /   |   B501
;        /    |    |
;     B201->B202  B502
;             \  /
;              B6 (phi: divergent)
;
;
; CHECK-LABEL:  'test_ctrl_divergence':
; CHECK-LABEL:  BLOCK Entry
; CHECK:  DIVERGENT:   %div.cond = icmp eq i32 %tid, 0
; CHECK:  DIVERGENT:   br i1 %div.cond, label %B3, label %B0
;
; CHECK-LABEL:  BLOCK B6
; CHECK:  DIVERGENT:   %div_a = phi i32 [ %a0, %B202 ], [ %a1, %B502 ]
; CHECK:  DIVERGENT:   %div_b = phi i32 [ %b0, %B202 ], [ %b1, %B502 ]
; CHECK:  DIVERGENT:   %div_c = phi i32 [ %c0, %B202 ], [ %c1, %B502 ]

define amdgpu_kernel void @test_ctrl_divergence(i32 %a, i32 %b, i32 %c, i32 %d) {
Alpha:
  %tid = call i32 @llvm.amdgcn.workitem.id.x()
  %div.uni = icmp eq i32 %a, 0
  br i1 %div.uni, label %Entry, label %B4

Entry:
  %div.cond = icmp eq i32 %tid, 0
  br i1 %div.cond, label %B3, label %B0 ; divergent branch

B0:
  br label %B1

B1:
  br label %B2

B2:
  %a0 = add i32 %a, 1
  %b0 = add i32 %b, 2
  %c0 = add i32 %c, 3
  br i1 %div.uni, label %B201, label %B202

B201:
  br label %B202

B202:
  br label %B6

B3:
  br label %B4

B4:
  %a1 = add i32 %a, 10
  %b1 = add i32 %b, 20
  %c1 = add i32 %c, 30
  br i1 %div.uni, label %B5, label %B501

B5:
  br label %B501

B501:
  br label %B502

B502:
  br label %B6

B6:
  %div_a = phi i32 [%a0, %B202], [%a1,  %B502]
  %div_b = phi i32 [%b0, %B202], [%b1,  %B502]
  %div_c = phi i32 [%c0, %B202], [%c1,  %B502]
  ret void
}


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

attributes #0 = {nounwind readnone }