Skip to content

[SPIR-V] Invalid generated SPIR-V when nesting HLSL 2021 and intrinsic. #6995

Description

@Mr-Wiseguy

Description
In an attempt to minimize branching in our HLSL 2021 shader code, we have been converting boolean operators to use the and intrinsic from HLSL 2021 that doesn't short circuit. However, when nesting two calls to and, we get the following error:
fatal error: generated SPIR-V is invalid: Expected both operands to be of Result Type: LogicalAnd

Steps to Reproduce
https://shader-playground.timjones.io/a2afd625eb79aac130756befae206296
https://godbolt.org/z/vfn3Kxc7W

Environment

  • Tested latest July 2024 release and latest trunk on godbolt (5704c47)

Activity

  1. added
    bug
    needs-triage
    spirv
    on Nov 1, 2024
  2. s-perron commented on Nov 18, 2024

    @s-perron
    Collaborator

    This is incorrect even with just a single and (https://godbolt.org/z/Te48c9zzz). The AST for the call to and is:

      |         |-ImplicitCastExpr 0x56546c5b52c8 <col:12> 'bool (*)(int, int)' <FunctionToPointerDecay>
      |         | `-DeclRefExpr 0x56546c5b5260 <col:12> 'bool (int, int)' lvalue Function 0x56546c5b5048 'and' 'bool (int, int)'
    

    It treats the parameters as integers. However, the spir-v instruction takes bools. Should be an easy fix.

  3. moved this from For Google to Triaged in HLSL Triageon Nov 18, 2024
  4. added a commit that references this issue on Jan 10, 2025
    62dcf74
  5. moved this from New to In review in HLSL Roadmapon Jan 10, 2025
  6. added a commit that references this issue on Jan 13, 2025
    b5ad532
  7. moved this from In review to Done in HLSL Roadmapon Jan 22, 2025
  8. added a commit that references this issue on Jan 24, 2025
    25faa88
  9. added 5 commits that reference this issue on Jan 27, 2025
    707eb03
    db98699
    ef1472a
    9a9b37f
    d6dc036
  10. added a commit that references this issue on Jul 24, 2025
    40a3cf7
  11. added a commit that references this issue on Feb 13, 2026
    3447d41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugspirv

Type

No type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions