File: return-early.ll

package info (click to toggle)
llvm-toolchain-20 1%3A20.1.6-1~exp1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 2,111,304 kB
  • sloc: cpp: 7,438,677; ansic: 1,393,822; asm: 1,012,926; python: 241,650; f90: 86,635; objc: 75,479; lisp: 42,144; pascal: 17,286; sh: 10,027; ml: 5,082; perl: 4,730; awk: 3,523; makefile: 3,349; javascript: 2,251; xml: 892; fortran: 672
file content (139 lines) | stat: -rw-r--r-- 4,873 bytes parent folder | download | duplicates (6)
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
; RUN: llc -mtriple=spirv-unknown-vulkan-compute -O0 %s -o - | FileCheck %s
; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-unknown-vulkan-compute %s -o - -filetype=obj | spirv-val %}

; CHECK-DAG:         OpName %[[#reg_0:]] "reg2"
; CHECK-DAG:         OpName %[[#reg_1:]] "reg1"

target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-G1"
target triple = "spirv-unknown-vulkan1.3-compute"

define internal spir_func void @main() #0 {
; CHECK: %[[#entry:]] = OpLabel
; CHECK:                OpBranch %[[#while_cond:]]
entry:
  %0 = call token @llvm.experimental.convergence.entry()
  %a = alloca i32, align 4
  %b = alloca i32, align 4
  %cond = alloca i32, align 4
  %i = alloca i32, align 4
  store i32 1, ptr %cond, align 4
  br label %while.cond

; CHECK: %[[#while_cond]] = OpLabel
; CHECK:                    OpSelectionMerge %[[#while_end:]] None
; CHECK:                    OpBranchConditional %[[#cond:]] %[[#while_body:]] %[[#while_end]]
while.cond:
  %1 = call token @llvm.experimental.convergence.loop() [ "convergencectrl"(token %0) ]
  %2 = load i32, ptr %cond, align 4
  %tobool = icmp ne i32 %2, 0
  br i1 %tobool, label %while.body, label %while.end

; CHECK: %[[#while_body]] = OpLabel
; CHECK:                    OpSelectionMerge %[[#switch_end:]] None
; CHECK:                    OpSwitch %[[#cond:]] %[[#switch_end]] 1 %[[#case_1:]] 2 %[[#case_2:]] 5 %[[#case_5:]]
while.body:
  %3 = load i32, ptr %b, align 4
  switch i32 %3, label %sw.default [
    i32 1, label %sw.bb
    i32 2, label %sw.bb1
    i32 5, label %sw.bb2
  ]

; CHECK: %[[#case_5]] = OpLabel
; CHECK:                OpStore %[[#reg_0]] %[[#]]
; CHECK:                OpBranch %[[#switch_end]]
sw.bb2:
  store i32 5, ptr %a, align 4
  br label %while.end

; CHECK: %[[#case_2]] = OpLabel
; CHECK:                OpStore %[[#reg_0]] %[[#]]
; CHECK:                OpBranch %[[#switch_end]]
sw.bb1:
  store i32 3, ptr %a, align 4
  br label %while.end

; CHECK: %[[#case_1]] = OpLabel
; CHECK:                OpStore %[[#reg_0]] %[[#]]
; CHECK:                OpBranch %[[#switch_end]]
sw.bb:
  store i32 1, ptr %a, align 4
  br label %while.end

; CHECK: %[[#switch_end]] = OpLabel
; CHECK:       %[[#val:]] = OpLoad %[[#]] %[[#reg_0]]
; CHECK:       %[[#tmp:]] = OpIEqual %[[#type:]] %[[#]] %[[#val]]
; CHECK:                    OpBranchConditional %[[#tmp]] %[[#sw_default:]] %[[#while_end]]

; CHECK: %[[#sw_default]] = OpLabel
; CHECK:                    OpStore %[[#]] %[[#B:]] Aligned 4
; CHECK:                    OpBranch %[[#for_cond:]]
sw.default:
  store i32 0, ptr %i, align 4
  br label %for.cond

; CHECK: %[[#for_cond]] = OpLabel
; CHECK:                  OpStore %[[#reg_1]] %[[#]]
; CHECK:                  OpSelectionMerge %[[#for_merge:]] None
; CHECK-NEXT:             OpBranchConditional %[[#cond:]] %[[#for_merge]] %[[#for_end:]]
for.cond:
  %4 = call token @llvm.experimental.convergence.loop() [ "convergencectrl"(token %1) ]
  %5 = load i32, ptr %i, align 4
  %cmp = icmp slt i32 %5, 10
  br i1 %cmp, label %for.body, label %for.end

; CHECK: %[[#for_end]] = OpLabel
; CHECK:                 OpStore %[[#reg_1]] %[[#]]
; CHECK:                 OpBranch %[[#for_merge]]
for.end:
  br label %while.end

; CHECK: %[[#for_merge]] = OpLabel
; CHECK:      %[[#val:]] = OpLoad %[[#]] %[[#reg_1]]
; CHECK:      %[[#tmp:]] = OpIEqual %[[#type:]] %[[#]] %[[#val]]
; CHECK:                   OpBranchConditional %[[#tmp]] %[[#for_body:]] %[[#while_end]]

; CHECK: %[[#for_body]] = OpLabel
; CHECK:                  OpSelectionMerge %[[#if_merge:]] None
; CHECK:                  OpBranchConditional %[[#cond:]] %[[#if_merge]] %[[#if_else:]]
for.body:
  %6 = load i32, ptr %cond, align 4
  %tobool3 = icmp ne i32 %6, 0
  br i1 %tobool3, label %if.then, label %if.else

; CHECK: %[[#if_else]] = OpLabel
; CHECK:                 OpBranch %[[#if_merge]]
if.else:
  br label %while.end

; CHECK: %[[#if_merge]] = OpLabel
; CHECK:                  OpBranch %[[#while_end]]
if.then:
  br label %while.end

; CHECK: %[[#while_end]] = OpLabel
; CHECK:                   OpReturn
while.end:
  ret void

; CHECK-NOT: %[[#for_inc:]] = OpLabel
; This block is not emitted since it's unreachable.
for.inc:
  %7 = load i32, ptr %i, align 4
  %inc = add nsw i32 %7, 1
  store i32 %inc, ptr %i, align 4
  br label %for.cond

}

declare token @llvm.experimental.convergence.entry() #1
declare token @llvm.experimental.convergence.loop() #1

attributes #0 = { convergent noinline norecurse nounwind optnone "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
attributes #1 = { convergent nocallback nofree nosync nounwind willreturn memory(none) }

!llvm.module.flags = !{!0, !1, !2}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 4, !"dx.disable_optimizations", i32 1}
!2 = !{i32 7, !"frame-pointer", i32 2}