1 ; RUN: llc -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s
2 ; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv32-unknown-unknown %s -o - -filetype=obj | spirv-val %}
5 ; CHECK: OpBranchConditional %[[#]] %[[#if_then:]] %[[#if_end:]]
6 ; CHECK: %[[#if_then]] = OpLabel
7 ; CHECK: OpBranch %[[#if_end]]
8 ; CHECK: %[[#if_end]] = OpLabel
9 ; CHECK: %[[#Var:]] = OpPhi
10 ; CHECK: OpSwitch %[[#Var]] %[[#]] [[#]] %[[#]] [[#]] %[[#]] [[#]] %[[#]] [[#]] %[[#]] [[#]] %[[#]] [[#]] %[[#]] [[#]] %[[#]] [[#]] %[[#]] [[#]] %[[#]] [[#]] %[[#]] [[#]] %[[#]] [[#]] %[[#]]
11 ; CHECK-COUNT-10: OpLabel
12 ; CHECK: %[[#epilog:]] = OpLabel
13 ; CHECK: OpBranch %[[#exit:]]
14 ; CHECK: %[[#exit]] = OpLabel
17 ; CHECK-NEXT: OpFunctionEnd
19 define spir_func void @foo(i64 noundef %addr, i64 noundef %as) {
21 %src = inttoptr i64 %as to ptr addrspace(4)
22 %val = load i8, ptr addrspace(4) %src
23 %cmp = icmp sgt i8 %val, 0
24 br i1 %cmp, label %if.then, label %if.end
27 %add.ptr = getelementptr inbounds i8, ptr addrspace(4) %src, i64 1
28 %cond = load i8, ptr addrspace(4) %add.ptr
32 %swval = phi i8 [ %cond, %if.then ], [ %val, %entry ]
33 switch i8 %swval, label %sw.default [
34 i8 -127, label %sw.epilog
35 i8 -126, label %sw.bb3
36 i8 -125, label %sw.bb4
37 i8 -111, label %sw.bb5
38 i8 -110, label %sw.bb6
39 i8 -109, label %sw.bb7
43 i8 -124, label %sw.bb9
44 i8 -95, label %sw.bb10
45 i8 -123, label %sw.bb11