Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bitfields generate bad code when casted #7074

Open
llvm-beanz opened this issue Jan 16, 2025 · 1 comment
Open

Bitfields generate bad code when casted #7074

llvm-beanz opened this issue Jan 16, 2025 · 1 comment
Labels
bug Bug, regression, crash needs-triage Awaiting triage

Comments

@llvm-beanz
Copy link
Collaborator

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
@llvm-beanz llvm-beanz added bug Bug, regression, crash needs-triage Awaiting triage labels Jan 16, 2025
@s-perron
Copy link
Collaborator

s-perron commented Jan 17, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug, regression, crash needs-triage Awaiting triage
Projects
Status: No status
Development

No branches or pull requests

2 participants