Files
OpenCL-CTS/test_conformance/spirv_new/spirv_asm/phi_2.spvasm64
Ahmed Hesham 5d85fb3e3b Use cl_uint in some SPIR-V tests to avoid UB (#2159)
The following tests under `spirv_new`:
* `op_branch_conditional`
* `op_phi`
* `op_selection_merge`

were using randomly generated `cl_int` values, and storing the
difference between them as a `cl_int`. If one of the generated values is
negative and large enough, while the other is positive and large enough,
the difference then becomes a larger value that cannot be represented
using `cl_int`.

Switch the tests to use `cl_uint` instead, and update the relevant
spvasm{32,64} files to use `OpULessThan` instead of `OpSLessThan`.

Signed-off-by: Ahmed Hesham <ahmed.hesham@arm.com>
2024-11-26 09:29:27 -08:00

58 lines
2.4 KiB
Plaintext

; SPIR-V
; Version: 1.0
; Generator: Khronos SPIR-V Tools Assembler; 0
; Bound: 33
; Schema: 0
OpCapability Addresses
OpCapability Linkage
OpCapability Kernel
OpCapability Int64
OpMemoryModel Physical64 OpenCL
OpEntryPoint Kernel %1 "phi_2" %gl_GlobalInvocationID
OpName %res "res"
OpName %lhs "lhs"
OpName %rhs "rhs"
OpDecorate %5 FuncParamAttr NoCapture
%5 = OpDecorationGroup
OpDecorate %gl_GlobalInvocationID BuiltIn GlobalInvocationId
OpDecorate %gl_GlobalInvocationID Constant
OpDecorate %gl_GlobalInvocationID LinkageAttributes "__spirv_GlobalInvocationId" Import
OpGroupDecorate %5 %res %lhs %rhs
%ulong = OpTypeInt 64 0
%v3ulong = OpTypeVector %ulong 3
%_ptr_Input_v3ulong = OpTypePointer Input %v3ulong
%ulong_32 = OpConstant %ulong 32
%bool = OpTypeBool
%void = OpTypeVoid
%uint = OpTypeInt 32 0
%_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint
%15 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_uint
%gl_GlobalInvocationID = OpVariable %_ptr_Input_v3ulong Input
%1 = OpFunction %void None %15
%res = OpFunctionParameter %_ptr_CrossWorkgroup_uint
%lhs = OpFunctionParameter %_ptr_CrossWorkgroup_uint
%rhs = OpFunctionParameter %_ptr_CrossWorkgroup_uint
%16 = OpLabel
%17 = OpLoad %v3ulong %gl_GlobalInvocationID Aligned 0
%18 = OpCompositeExtract %ulong %17 0
%19 = OpShiftLeftLogical %ulong %18 %ulong_32
%20 = OpShiftRightArithmetic %ulong %19 %ulong_32
%21 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %lhs %20
%22 = OpLoad %uint %21 Aligned 4
%23 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %rhs %20
%24 = OpLoad %uint %23 Aligned 4
%25 = OpULessThan %bool %22 %24
OpBranchConditional %25 %26 %27
%26 = OpLabel
%28 = OpISub %uint %24 %22
OpBranch %29
%27 = OpLabel
%30 = OpISub %uint %22 %24
OpBranch %29
%29 = OpLabel
%31 = OpPhi %uint %28 %26 %30 %27
%32 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %res %20
OpStore %32 %31 Aligned 4
OpReturn
OpFunctionEnd