| 1 |
; The goal of the test case is to ensure that PHI node has an incoming value per each predecessor |
| 2 |
; instance even if the input SPIR-V module is invalid as reported by spirv-val. |
| 3 |
|
| 4 |
; We don't run spirv-val on this module therefore. |
| 5 |
|
| 6 |
; REQUIRES: spirv-as |
| 7 |
; RUN: spirv-as --target-env spv1.0 -o %t.spv %s |
| 8 |
; RUN: llvm-spirv -r -o - %t.spv | llvm-dis | FileCheck %s |
| 9 |
|
| 10 |
OpCapability Kernel |
| 11 |
OpCapability Addresses |
| 12 |
OpCapability Int64 |
| 13 |
OpCapability Linkage |
| 14 |
%1 = OpExtInstImport "OpenCL.std" |
| 15 |
OpMemoryModel Physical64 OpenCL |
| 16 |
OpSource OpenCL_CPP 100000 |
| 17 |
OpName %foo "foo" |
| 18 |
OpName %get "get" |
| 19 |
OpDecorate %foo LinkageAttributes "foo" Export |
| 20 |
OpDecorate %get LinkageAttributes "get" Import |
| 21 |
%uint = OpTypeInt 32 0 |
| 22 |
%3 = OpTypeFunction %uint |
| 23 |
%ulong = OpTypeInt 64 0 |
| 24 |
%uint_2 = OpConstant %uint 2 |
| 25 |
%uint_4 = OpConstant %uint 4 |
| 26 |
%get = OpFunction %uint None %3 |
| 27 |
OpFunctionEnd |
| 28 |
%foo = OpFunction %uint None %3 |
| 29 |
%11 = OpLabel |
| 30 |
%9 = OpFunctionCall %uint %get |
| 31 |
OpSwitch %9 %12 10 %13 4 %13 0 %13 42 %13 |
| 32 |
%12 = OpLabel |
| 33 |
OpBranch %13 |
| 34 |
%13 = OpLabel |
| 35 |
%10 = OpPhi %uint %uint_4 %11 %uint_4 %11 %uint_4 %11 %uint_4 %11 %uint_2 %12 |
| 36 |
%14 = OpPhi %uint %uint_2 %12 %uint_4 %11 %uint_4 %11 %uint_4 %11 %uint_4 %11 |
| 37 |
OpReturnValue %14 |
| 38 |
OpFunctionEnd |
| 39 |
|
| 40 |
; CHECK: phi i32 [ 4, %0 ], [ 4, %0 ], [ 4, %0 ], [ 4, %0 ], [ 2, %2 ] |
| 41 |
; CHECK: phi i32 [ 2, %2 ], [ 4, %0 ], [ 4, %0 ], [ 4, %0 ], [ 4, %0 ] |