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

[HLSL] [branch] attribute support for switch statements #125754

Closed
Tracked by #21 ...
llvm-beanz opened this issue Feb 4, 2025 · 2 comments · Fixed by #131739
Closed
Tracked by #21 ...

[HLSL] [branch] attribute support for switch statements #125754

llvm-beanz opened this issue Feb 4, 2025 · 2 comments · Fixed by #131739
Assignees
Labels
clang:codegen IR generation bugs: mangling, exceptions, etc. HLSL HLSL Language Support

Comments

@llvm-beanz
Copy link
Collaborator

HLSL supports the branch attribute on switch statements. Clang currently errors if you apply the [branch] attribute to a switch statement.

RWBuffer<uint4> Buf;

[numthreads(8,1,1)]
void main(uint GI : SV_GroupIndex) {
  uint4 Val = Buf[GI];
  [branch]
  switch (Val.x) {
    case 0:
      Buf[GI] = Val.xxxx;
      break;
    case 1:
      Buf[GI] = Val.yyyy;
      break;
    case 2:
      Buf[GI] = Val.zzzz;
      break;
    default:
      Buf[GI] = Val.wwww;
      break;
  }
}

Godbolt

@llvm-beanz llvm-beanz added the HLSL HLSL Language Support label Feb 4, 2025
@llvm-beanz llvm-beanz moved this to Planning in HLSL Support Feb 4, 2025
@damyanp damyanp moved this from Planning to Designing in HLSL Support Feb 11, 2025
@damyanp
Copy link
Contributor

damyanp commented Feb 11, 2025

We need to do some investigation before we attempt to estimate this.

@joaosaffran joaosaffran self-assigned this Mar 18, 2025
@joaosaffran joaosaffran moved this from Designing to Needs Review in HLSL Support Mar 18, 2025
joaosaffran added a commit that referenced this issue Mar 24, 2025
@github-project-automation github-project-automation bot moved this from Needs Review to Closed in HLSL Support Mar 24, 2025
llvm-sync bot pushed a commit to arm/arm-toolchain that referenced this issue Mar 24, 2025
@EugeneZelenko EugeneZelenko added the clang:codegen IR generation bugs: mangling, exceptions, etc. label Mar 24, 2025
@llvmbot
Copy link
Member

llvmbot commented Mar 24, 2025

@llvm/issue-subscribers-clang-codegen

Author: Chris B (llvm-beanz)

HLSL supports the `branch` attribute on `switch` statements. Clang currently errors if you apply the `[branch]` attribute to a switch statement.
RWBuffer&lt;uint4&gt; Buf;

[numthreads(8,1,1)]
void main(uint GI : SV_GroupIndex) {
  uint4 Val = Buf[GI];
  [branch]
  switch (Val.x) {
    case 0:
      Buf[GI] = Val.xxxx;
      break;
    case 1:
      Buf[GI] = Val.yyyy;
      break;
    case 2:
      Buf[GI] = Val.zzzz;
      break;
    default:
      Buf[GI] = Val.wwww;
      break;
  }
}

Godbolt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:codegen IR generation bugs: mangling, exceptions, etc. HLSL HLSL Language Support
Projects
Status: Closed
Development

Successfully merging a pull request may close this issue.

5 participants