intel / intel/llvm

CTAD bug in vector length

Open
#6,402 2 comments 0 reactions 0 assignees View on GitHub
bug confirmed
Dominant language
LLVM
Stars
1.5k
Forks
854
Avg merge
3d 17h
Merged PRs (30d)
137

Description

**Describe the bug**
Swizzled vector types can't be passed directly to `length()` because `detail::is_gengeohalf::value` is `false` for these types.

From [this StackOverflow question](https://stackoverflow.com/questions/72877944/automatically-convert-sycl-swizzle-operation-to-vector).

**To Reproduce**

``` c++
#define SYCL_SIMPLE_SWIZZLES
#include

using namespace sycl;

int main(){
float3 myVec{1.0, 0.0, 2.0};
auto len = length(myVec.zy());
}
```

The above code fails to compile because it cant deduce typename T of `length` (should be `float2`?) If one instead has
```c++
auto len = length(myVec.zy());
```
it works fine.

**Additional context**

`length()` is defined in builtins.hpp:

``` c++
// float length (gengeofloat p)
template ::value, T>>
float length(T p) __NOEXC {
return __sycl_std::__invoke_length(p);
}
```
and `detail::is_gengeofloat` is only `true` for `type_list, vec, vec, vec>`.

I'm not sure if the solution is to include the SwizzleOp types in `geo_float_list` or to define a specialization for `length` etc for SwizzleOp types, but as the StackOverflow OP points out, this somewhat defeats the purpose of swizzle convenience operations.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.