这是indexloc提供的服务,不要输入任何密码
Skip to content

Rule for mixed-signedness operands to integer div, rem, less-than, greater-than, less-or-equal, greater-or-equal #707

@dneto0

Description

@dneto0

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    wgslWebGPU Shading Language Issues

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions