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

asuint doesn't accept signed integer vector literals #6851

Closed
sudonatalie opened this issue Aug 7, 2024 · 3 comments
Closed

asuint doesn't accept signed integer vector literals #6851

sudonatalie opened this issue Aug 7, 2024 · 3 comments
Labels
bug Bug, regression, crash needs-triage Awaiting triage

Comments

@sudonatalie
Copy link
Collaborator

sudonatalie commented Aug 7, 2024

Description
Validation fails when asuint is passed a vector literal of signed integers. Of course, this is something that only comes up in generated code where the literal isn't known ahead of time. If this is intended behavior, it seems like at least the error messaging should be improved.

Steps to Reproduce
dxc -T cs_6_6

RWByteAddressBuffer prevent_dce : register(u0);

[numthreads(1, 1, 1)]
void main() {
  int arg = -1;
  int3 vec = (-1).xxx;
  prevent_dce.Store3(0u, arg); // !!! WORKS
  prevent_dce.Store3(0u, asuint(-1)); // !!! WORKS
  prevent_dce.Store3(0u, vec); // !!! WORKS
  prevent_dce.Store3(0u, asuint((-1).xxx)); // !!! FAILS
  return;
}

https://godbolt.org/z/YcE8c1hqa

Expected Behavior
Compilation succeeds, or a relevant error message is produced.

Actual Behavior

error: validation errors
Invalid record
Validation failed.

Environment

  • DXC version: libdxcompiler.so: 1.8(dev;4705-99f2d498)
  • Host Operating System: Linux
@sudonatalie sudonatalie added bug Bug, regression, crash needs-triage Awaiting triage labels Aug 7, 2024
@llvm-beanz
Copy link
Collaborator

This one works in 202x. Unsure what exactly is happening here, but this is likely some odd explosion of the literal to 64-bits. We have some known issues with storing literals to ByteAddressBuffer causing 64-bit stores instead of 32-bit stores (see: #5493).

I don't know if you're going to want to adopt an experimental in-development language version, but HLSL 202x fixes this issue as part of this feature proposal (https://github.com/microsoft/hlsl-specs/blob/main/proposals/0017-conforming-literals.md)

@damyanp
Copy link
Member

damyanp commented Aug 8, 2024

As this is fixed in 202x, no plans at moment to go back and address this for older language versions. Happy to hear feedback on why we should consider this higher priority.

@damyanp damyanp closed this as not planned Won't fix, can't repro, duplicate, stale Aug 8, 2024
@github-project-automation github-project-automation bot moved this to Triaged in HLSL Triage Aug 8, 2024
@sudonatalie
Copy link
Collaborator Author

No problem, we're working around it by extracting the literal to a var.

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
Archived in project
Development

No branches or pull requests

3 participants