Issue 202737
Summary [SPIR-V] Aggregate `OpSelect` lowering assumes SPIR-V >= 1.4
Labels new issue
Assignees
Reporter maleadt
    #201417 adds lowering for `select` instructions whose operands are aggregates (arrays or structs). The lowering emits an `OpSelect` whose result type is the composite type.

Selecting between array- or struct-typed objects was added to `OpSelect` in SPIR-V 1.4. In 1.3 and earlier, `OpSelect` only accepts a scalar or vector result type. So when the target version is below 1.4, the backend emits an `OpSelect` the target environment rejects, and there is no fallback lowering.

Repro:

```llvm
; llc -O0 -mtriple=spirv64v1.3-unknown-unknown %s -o - -filetype=obj | spirv-val --target-env spv1.3
define spir_kernel void @f(ptr addrspace(1) %out, i1 %c) {
  %v = select i1 %c, [2 x float] [float 1.000000e+00, float 0.000000e+00], [2 x float] zeroinitializer
  %e0 = extractvalue [2 x float] %v, 0
  store float %e0, ptr addrspace(1) %out
  ret void
}
```

The module is tagged `; Version: 1.3` but still contains a composite `OpSelect`, which spirv-val rejects:

```
error: line 27: Expected scalar or vector type as Result Type: Select
  %17 = OpSelect %_arr_float_uint_2 %c %12 %13
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to