[gn build] Port 0154dce8d39d
[llvm-project.git] / llvm / test / CodeGen / SPIRV / opencl / device_execution / execute_block.ll
blob562f5c7b6826e108cdd1477b368de4d11e17b9d4
1 ; RUN: llc -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s
3 ; REQUIRES: asserts
5 ; CHECK: %[[#bool:]] = OpTypeBool
6 ; CHECK: %[[#true:]] = OpConstantTrue %[[#bool]]
7 ; CHECK: OpBranchConditional %[[#true]]
9 %structtype = type { i32, i32, i8 addrspace(4)* }
10 %structtype.0 = type <{ i32, i32, i8 addrspace(4)* }>
12 @__block_literal_global = internal addrspace(1) constant %structtype { i32 16, i32 8, i8 addrspace(4)* addrspacecast (i8* null to i8 addrspace(4)*) }, align 8
13 @__block_literal_global.1 = internal addrspace(1) constant %structtype { i32 16, i32 8, i8 addrspace(4)* addrspacecast (i8* null to i8 addrspace(4)*) }, align 8
14 @__block_literal_global.2 = internal addrspace(1) constant %structtype { i32 16, i32 8, i8 addrspace(4)* addrspacecast (i8* null to i8 addrspace(4)*) }, align 8
16 define spir_kernel void @block_typedef_mltpl_stmnt(i32 addrspace(1)* %res) {
17 entry:
18   %0 = call spir_func <3 x i64> @BuiltInGlobalInvocationId()
19   %call = extractelement <3 x i64> %0, i32 0
20   %arrayidx = getelementptr inbounds i32, i32 addrspace(1)* %res, i64 %call
21   store i32 -1, i32 addrspace(1)* %arrayidx, align 4
22   %1 = bitcast %structtype addrspace(1)* @__block_literal_global to i8 addrspace(1)*
23   %2 = addrspacecast i8 addrspace(1)* %1 to i8 addrspace(4)*
24   %3 = bitcast %structtype addrspace(1)* @__block_literal_global.1 to i8 addrspace(1)*
25   %4 = addrspacecast i8 addrspace(1)* %3 to i8 addrspace(4)*
26   %5 = bitcast %structtype addrspace(1)* @__block_literal_global.2 to i8 addrspace(1)*
27   %6 = addrspacecast i8 addrspace(1)* %5 to i8 addrspace(4)*
28   br label %do.body
30 do.body:                                          ; preds = %do.cond, %entry
31   %a.0 = phi i32 [ undef, %entry ], [ %a.1, %do.cond ]
32   %call1 = call spir_func float @__block_typedef_mltpl_stmnt_block_invoke(i8 addrspace(4)* %2, float 0.000000e+00)
33   %call2 = call spir_func i32 @__block_typedef_mltpl_stmnt_block_invoke_2(i8 addrspace(4)* %4, i32 0)
34   %conv = sitofp i32 %call2 to float
35   %sub = fsub float %call1, %conv
36   %cmp = fcmp ogt float %sub, 0.000000e+00
37   br i1 %cmp, label %if.then, label %if.end
39 if.then:                                          ; preds = %do.body
40   %call4 = call spir_func i32 @__block_typedef_mltpl_stmnt_block_invoke_3(i8 addrspace(4)* %6, i32 1)
41   %call5 = call spir_func i32 @__block_typedef_mltpl_stmnt_block_invoke_3(i8 addrspace(4)* %6, i32 2)
42   %add = add i32 %call4, %call5
43   br label %cleanup
45 if.end:                                           ; preds = %do.body
46   br label %cleanup
48 cleanup:                                          ; preds = %if.end, %if.then
49   %a.1 = phi i32 [ %add, %if.then ], [ %a.0, %if.end ]
50   %cleanup.dest.slot.0 = phi i32 [ 2, %if.then ], [ 0, %if.end ]
51   switch i32 %cleanup.dest.slot.0, label %unreachable [
52     i32 0, label %cleanup.cont
53     i32 2, label %do.end
54   ]
56 cleanup.cont:                                     ; preds = %cleanup
57   br label %do.cond
59 do.cond:                                          ; preds = %cleanup.cont
60   br i1 true, label %do.body, label %do.end
62 do.end:                                           ; preds = %do.cond, %cleanup
63   %sub7 = sub nsw i32 %a.1, 11
64   %arrayidx8 = getelementptr inbounds i32, i32 addrspace(1)* %res, i64 %call
65   store i32 %sub7, i32 addrspace(1)* %arrayidx8, align 4
66   ret void
68 unreachable:                                      ; preds = %cleanup
69   unreachable
72 define internal spir_func float @__block_typedef_mltpl_stmnt_block_invoke(i8 addrspace(4)* %.block_descriptor, float %bi) {
73 entry:
74   %block = bitcast i8 addrspace(4)* %.block_descriptor to %structtype.0 addrspace(4)*
75   %conv = fpext float %bi to double
76   %add = fadd double %conv, 3.300000e+00
77   %conv1 = fptrunc double %add to float
78   ret float %conv1
81 define internal spir_func i32 @__block_typedef_mltpl_stmnt_block_invoke_2(i8 addrspace(4)* %.block_descriptor, i32 %bi) {
82 entry:
83   %block = bitcast i8 addrspace(4)* %.block_descriptor to %structtype.0 addrspace(4)*
84   %add = add nsw i32 %bi, 2
85   ret i32 %add
88 define internal spir_func i32 @__block_typedef_mltpl_stmnt_block_invoke_3(i8 addrspace(4)* %.block_descriptor, i32 %bi) {
89 entry:
90   %block = bitcast i8 addrspace(4)* %.block_descriptor to %structtype.0 addrspace(4)*
91   %add = add i32 %bi, 4
92   ret i32 %add
95 declare spir_func <3 x i64> @BuiltInGlobalInvocationId()