Debian Codegraph @

llvm-project/llvm/projects/llvm-spirv/test/transcoding/OpSwitch32.ll

raw
1 ;__kernel void test_32(__global int* res)
2 ;{
3 ; int tid = get_global_id(0);
4 ;
5 ; switch(tid)
6 ; {
7 ; case 0:
8 ; res[tid] = 1;
9 ; break;
10 ; case 1:
11 ; res[tid] = 2;
12 ; break;
13 ; }
14 ;}
15 ; bash$ clang -cc1 -triple spir64-unknown-unknown -x cl -cl-std=CL2.0 -O0 -include opencl.h -emit-llvm OpSwitch.cl -o test_32.ll
16
17 ; RUN: llvm-as %s -o %t.bc
18 ; RUN: llvm-spirv %t.bc -spirv-text -o %t.spt
19 ; RUN: FileCheck < %t.spt %s --check-prefix=CHECK-SPIRV
20 ; RUN: llvm-spirv %t.bc -o %t.spv
21 ; RUN: spirv-val %t.spv
22 ; RUN: llvm-spirv -r -emit-opaque-pointers %t.spv -o %t.bc
23 ; RUN: llvm-dis < %t.bc | FileCheck %s --check-prefix=CHECK-LLVM
24
25 ; CHECK-SPIRV: 7 Switch {{[0-9]+}} {{[0-9]+}} 0 {{[0-9]+}} 1 {{[0-9]+}}
26
27 ; ModuleID = 'main'
28 target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64"
29 target triple = "spir64-unknown-unknown"
30
31 ;CHECK-LLVM: test_32
32 ;CHECK-LLVM: entry
33 ;CHECK-LLVM: switch i32 %[[#]], label %sw.epilog
34 ;CHECK-LLVM: i32 0, label %sw.bb
35 ;CHECK-LLVM: i32 1, label %sw.bb1
36
37 ; Function Attrs: nounwind
38 define spir_kernel void @test_32(ptr addrspace(1) %res) #0 !kernel_arg_addr_space !1 !kernel_arg_access_qual !2 !kernel_arg_type !3 !kernel_arg_base_type !4 !kernel_arg_type_qual !5 {
39 entry:
40 %res.addr = alloca ptr addrspace(1), align 8
41 %tid = alloca i32, align 4
42 store ptr addrspace(1) %res, ptr %res.addr, align 8
43 %call = call spir_func i64 @_Z13get_global_idj(i32 0) #2
44 %conv = trunc i64 %call to i32
45 store i32 %conv, ptr %tid, align 4
46 %0 = load i32, ptr %tid, align 4
47 switch i32 %0, label %sw.epilog [
48 i32 0, label %sw.bb
49 i32 1, label %sw.bb1
50 ]
51
52 ;CHECK-LLVM: sw.bb
53 ;CHECK-LLVM: preds = %entry
54 sw.bb: ; preds = %entry
55 %1 = load i32, ptr %tid, align 4
56 %idxprom = sext i32 %1 to i64
57 %2 = load ptr addrspace(1), ptr %res.addr, align 8
58 %arrayidx = getelementptr inbounds i32, ptr addrspace(1) %2, i64 %idxprom
59 store i32 1, ptr addrspace(1) %arrayidx, align 4
60 br label %sw.epilog
61
62 ;CHECK-LLVM: sw.bb1
63 ;CHECK-LLVM: preds = %entry
64 sw.bb1: ; preds = %entry
65 %3 = load i32, ptr %tid, align 4
66 %idxprom2 = sext i32 %3 to i64
67 %4 = load ptr addrspace(1), ptr %res.addr, align 8
68 %arrayidx3 = getelementptr inbounds i32, ptr addrspace(1) %4, i64 %idxprom2
69 store i32 2, ptr addrspace(1) %arrayidx3, align 4
70 br label %sw.epilog
71
72 ;CHECK-LLVM: sw.epilog
73 ;CHECK-LLVM: preds = %sw.bb1, %sw.bb, %entry
74 sw.epilog: ; preds = %entry, %sw.bb1, %sw.bb
75 ret void
76 }
77
78 ; Function Attrs: nounwind
79 declare spir_func i64 @_Z13get_global_idj(i32) #1
80
81 attributes #0 = { nounwind "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-realign-stack" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
82 attributes #1 = { nounwind "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-realign-stack" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
83 attributes #2 = { nounwind }
84
85 !opencl.enable.FP_CONTRACT = !{}
86 !opencl.spir.version = !{!6}
87 !opencl.ocl.version = !{!7}
88 !opencl.used.extensions = !{!8}
89 !opencl.used.optional.core.features = !{!8}
90 !opencl.compiler.options = !{!8}
91 !llvm.ident = !{!9}
92
93 !1 = !{i32 1}
94 !2 = !{!"none"}
95 !3 = !{!"int*"}
96 !4 = !{!"int*"}
97 !5 = !{!""}
98 !6 = !{i32 1, i32 2}
99 !7 = !{i32 2, i32 0}
100 !8 = !{}
101 !9 = !{!"clang version 3.6.1"}