In SPIR-V the rule on integer operations is that the signedness-semantics is determined by the opcode, not the signedness of the type of the operands
This is why, for example, it has both OpSLessThan, OpULessThan (for scalar integer values %a and %b of the same bit width):
%result = OpSLessThan %bool %a %b
- Ignore the signedness of operands %a and %b compare them as if they are both signed.
%result = OpULessThan %bool %a %b
- Ignore the signedness of operands %a and %b compare them as if they are both unsigned.
Similarly, there are "U" and "S" variants for Div, Rem, > , <=, >=
I think we might have touched on this issue in an earlier meeting but I don't recall a firm resolution or record in the WGSL spec.
I think the favoured option was:
- For these binary operations, it's only valid to have operands with consistent signedness. The programmer has to insert bit-level (reinterpretation) "as" casts in order to achieve signedness-consistency.
In SPIR-V the rule on integer operations is that the signedness-semantics is determined by the opcode, not the signedness of the type of the operands
This is why, for example, it has both OpSLessThan, OpULessThan (for scalar integer values %a and %b of the same bit width):
%result = OpSLessThan %bool %a %b%result = OpULessThan %bool %a %bSimilarly, there are "U" and "S" variants for Div, Rem, > , <=, >=
I think we might have touched on this issue in an earlier meeting but I don't recall a firm resolution or record in the WGSL spec.
I think the favoured option was: