Skip to content

Bitfields generate bad code when casted #7074

Open

Description

@llvm-beanz

Description
HLSL "Flat" casting bitfields does not properly mask bitfield members.

Steps to Reproduce
https://godbolt.org/z/MEKdTYxWM

Actual Behavior
Bit field members are read as full storage, not correctly masked, so instead of returning 3, this code returns 101057538 (0x6060402).

Environment

  • DXC version: main
  • Host Operating System: all

Activity

  1. added
    bug
    needs-triage
    on Jan 16, 2025
  2. s-perron commented on Jan 17, 2025

    @s-perron
    Collaborator

    If you are going to change this behaviour, you will need to update the SPIR-V backend to match it. We simply matched the DXIl behaviour when implementing. Nobody reported a bug related to bitfields, but we epxect that people will rely on unspecified behvaiour.

    See #4906 for the issue rleated to flat casting in spir-v.

    EDIT: Actually the spir-v code in this case is wrong in many different ways: https://godbolt.org/z/vcjGYM673.

  3. added
    hlsl2021
    check-in-clang
    and removed
    needs-triage
    on Jan 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugcheck-in-clanghlsl2021

    Type

    No type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions