KhronosGroup/SPIRV-LLVM

Wrong encoding of OpBuildNDRange

Closed this issue · 1 comments

Arguments order of OpBuildNDRange instruction is wrong.
SPIRV Spec
CL code:

kernel void test() {
  ndrange_t ndrange = ndrange_1D(123);
}

Expected:
OpBuildNDRange <Type> <id> GlobalWorkSize LocalWorkSize GlobalWorkOffset

         ...
         %13 = OpConstant %6 123
         %14 = OpConstant %6 0
          %4 = OpFunction %2 None %3
          %5 = OpLabel
         %11 = OpVariable %10 Function
         %12 = OpBuildNDRange %9 %13 %14 %14
               OpStore %11 %12
               OpReturn
               OpFunctionEnd

Actual:
OpBuildNDRange <Type> <id> GlobalWorkOffset GlobalWorkSize LocalWorkSize

         ...
         %13 = OpConstant %6 0
         %14 = OpConstant %6 123
         %15 = OpConstant %6 1
          %4 = OpFunction %2 None %3
          %5 = OpLabel
         %11 = OpVariable %10 Function
         %12 = OpBuildNDRange %9 %13 %14 %15
               OpStore %11 %12
               OpReturn
               OpFunctionEnd
bader commented

Fixed by pull request #56.