Skip to content

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

Closed
@llvm-beanz

Description

@llvm-beanz

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

Metadata

Metadata

Assignees

Labels

HLSLHLSL Language Supportclang:codegenIR generation bugs: mangling, exceptions, etc.

Type

No type

Projects

Status

Closed

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions