|
| 1 | +; RUN: %if spirv-tools %{ spirv-as %s -o - | spirv-val - %} |
| 2 | +; RUN: spirv-sim --function=simple --wave=4 --expects=0,2,2,4 -i %s |
| 3 | + OpCapability Shader |
| 4 | + OpCapability GroupNonUniform |
| 5 | + OpMemoryModel Logical GLSL450 |
| 6 | + OpEntryPoint GLCompute %main "main" %WaveIndex |
| 7 | + OpExecutionMode %main LocalSize 1 1 1 |
| 8 | + OpSource HLSL 670 |
| 9 | + OpName %simple "simple" |
| 10 | + OpName %main "main" |
| 11 | + OpDecorate %WaveIndex BuiltIn SubgroupLocalInvocationId |
| 12 | + %int = OpTypeInt 32 1 |
| 13 | + %uint = OpTypeInt 32 0 |
| 14 | + %bool = OpTypeBool |
| 15 | + %int_2 = OpConstant %int 2 |
| 16 | + %int_5 = OpConstant %int 5 |
| 17 | + %int_6 = OpConstant %int 6 |
| 18 | + %uint_0 = OpConstant %uint 0 |
| 19 | + %uint_2 = OpConstant %uint 2 |
| 20 | + %void = OpTypeVoid |
| 21 | + %main_type = OpTypeFunction %void |
| 22 | +%simple_type = OpTypeFunction %int |
| 23 | + %uint_iptr = OpTypePointer Input %uint |
| 24 | + %uint_fptr = OpTypePointer Function %uint |
| 25 | + %WaveIndex = OpVariable %uint_iptr Input |
| 26 | + %main = OpFunction %void None %main_type |
| 27 | + %unused = OpLabel |
| 28 | + OpReturn |
| 29 | + OpFunctionEnd |
| 30 | + %simple = OpFunction %int None %simple_type |
| 31 | + %entry = OpLabel |
| 32 | +; uint i = 0; |
| 33 | + %i = OpVariable %uint_fptr Function |
| 34 | + %1 = OpLoad %uint %WaveIndex |
| 35 | + OpStore %i %uint_0 |
| 36 | + OpBranch %header |
| 37 | + %header = OpLabel |
| 38 | + %2 = OpLoad %uint %i |
| 39 | + %3 = OpULessThan %bool %2 %1 |
| 40 | + OpLoopMerge %merge %continue None |
| 41 | + OpBranchConditional %3 %body %merge |
| 42 | +; while (i < WaveGetLaneIndex()) { |
| 43 | +; i += 2; |
| 44 | +; } |
| 45 | + %body = OpLabel |
| 46 | + OpBranch %continue |
| 47 | + %continue = OpLabel |
| 48 | + %4 = OpIAdd %uint %2 %uint_2 |
| 49 | + OpStore %i %4 |
| 50 | + OpBranch %header |
| 51 | + %merge = OpLabel |
| 52 | +; return (int) i; |
| 53 | + %5 = OpLoad %uint %i |
| 54 | + %6 = OpBitcast %int %5 |
| 55 | + OpReturnValue %6 |
| 56 | + OpFunctionEnd |
| 57 | + |
| 58 | + |
0 commit comments