[clang] [llvm] [HLSL] Handle WaveActiveBallot struct return type appropriately (PR #175105)

Farzon Lotfi via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 13 08:46:44 PST 2026


farzonl wrote:

Also this test should be failing `clang/test/CodeGenHLSL/builtins/WaveActiveBallot.hlsl`:

`lvm.spv.wave.ballot` doesn't  exist any more and `lvm.dx.wave.ballot` returns a struct. and the DXIL checks should be checking for the struct element value extracts and the vector inserts.  I would make the DXIL checks be check next to make sure you capture the full transformation.
```
// RUN: %clang_cc1 -finclude-default-header -fnative-half-type -triple \
// RUN:   dxil-pc-shadermodel6.3-compute %s -emit-llvm -disable-llvm-passes -o - | \
// RUN:   FileCheck %s --check-prefixes=CHECK,CHECK-DXIL
// RUN: %clang_cc1 -finclude-default-header -fnative-half-type -triple \
// RUN:   spirv-pc-vulkan-compute %s -emit-llvm -disable-llvm-passes -o - | \
// RUN:   FileCheck %s --check-prefixes=CHECK,CHECK-SPIRV

// Test basic lowering to runtime function call for int values.

// CHECK-LABEL: define {{.*}}test
uint4 test(bool p1) {
  // CHECK-SPIRV: %[[#entry_tok0:]] = call token @llvm.experimental.convergence.entry()
  // CHECK-SPIRV:  %[[RET:.*]] = call spir_func <4 x i32> @llvm.spv.wave.ballot(i1 %{{[a-zA-Z0-9]+}}) [ "convergencectrl"(token %[[#entry_tok0]]) ]
  // CHECK-DXIL:  %[[RET:.*]] = call <4 x i32> @llvm.dx.wave.ballot(i1 %{{[a-zA-Z0-9]+}})
  // CHECK:  ret <4 x i32> %[[RET]]
  return WaveActiveBallot(p1);
}

```

https://github.com/llvm/llvm-project/pull/175105


More information about the cfe-commits mailing list