[clang] [llvm] [HLSL][DXIL][SPIRV] Implementation of an abstraction for intrinsic selection of HLSL backends (PR #87171)

Nathan Gauër via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 2 05:01:14 PDT 2024


================
@@ -0,0 +1,95 @@
+; RUN: llc -O0 -mtriple=spirv-unknown-unknown %s -o - | FileCheck %s
+; Note: The validator is wrong it wants the return to be a bool vector when it is bool scalar return
----------------
Keenuts wrote:

AFAIK the validator is not wrong, it complains for 2 reasons:

`OpAll` cannot be used with a single boolean as input: It **must** be a vector of boolean.
And SPIR-V doesn't allow vector of 1 value.
Hence, `all(my_bool)` shall be translated to `return my_bool`.

Then, for int/long intrinsics:
HLSL only checks if the value (any type) is non-zero for all vector items.
for SPIR-V, `OpAll` only works for boolean vectors. This means the translation is not that straightforward.

What is being done in DXC is the following:

```
%const = OpConstantComposite %v2int %int_0 %int_0
%tmp = OpINotEqual %v2bool %variable %const
%res = OpAll %bool %tmp
```

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


More information about the cfe-commits mailing list