[clang] [llvm] [HLSL] implement elementwise firstbithigh hlsl builtin (PR #111082)

Justin Bogner via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 4 18:04:22 PDT 2024


bogner wrote:

It is not correct to limit firstbithigh to 32 bit integers. There are a couple of reasons that might make one think that it is, but we do in fact want/need to support int16 and int64 here.

1. The [HLSL docs](https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/firstbithigh) only mention integer. Unfortunately that's true for most of these functions, as many of these docs were not updated as 64 and 16 bit types gained support in the language.
2. DXC's SPIR-V implementation doesn't handle 16- and 64-bit for these functions. As noted in microsoft/DirectXShaderCompiler#4702 we decided not to implement those overloads in DXC, but should reconsider this for clang.

Despite all of this, DXC does indeed support 16- and 64-bit overloads, as seen here: https://hlsl.godbolt.org/z/qbc17xz35

Note that the return type of the operation is not overloaded - all of the overloads of this function return uint.

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


More information about the cfe-commits mailing list