microsoft / microsoft/DirectXShaderCompiler

[SPIR-V] Varying error behavior with bit functions on 16 bit types

Open
#6,864 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug crash spirv
Dominant language
C++
Stars
3.7k
Forks
900
Avg merge
2d 11h
Merged PRs (30d)
44

Description

Description

When using functions like firstbithigh, firstbitlow, and countbits, there are varying errors. The correct error is something along the lines of error: firstbithigh is currently limited to 32-bit width components when targetting SPIR-V however that isn't always the result.

Steps to Reproduce

Example of "correct" behavior:
https://godbolt.org/z/ecPqhxWGx
Example of segfault:
https://godbolt.org/z/4qYG1Y8Mv
Example of possibly correct, but more vague error:
https://godbolt.org/z/5x37qdnxs

Actual Behavior

I feel the correct behavior is, if asking for these ops to work for 16 bit values is off the table, for them to all produce the same error (and definitely not segfault)

Environment

  • DXC version 1.8.2407
  • Host Operating System - Windows version10.0.22621 Build 22621 (and also some version of ubuntu 22 but I don't know exactly)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the three linked Godbolt cases with DXC targeting SPIR-V, comparing firstbithigh, firstbitlow, and countbits on 16-bit types. Trace the diagnostics and the segfaulting case through the compiler's SPIR-V path; done means these operations consistently produce the intended unsupported-width error without crashing.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.