Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions sycl/include/sycl/vector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1207,6 +1207,16 @@ class SwizzleOp {
};

public:
template <int... swizzleIndexes>
ConstSwizzle<Indexer<swizzleIndexes>::value...> swizzle() const {
return m_Vector;
}

template <int... swizzleIndexes>
Swizzle<Indexer<swizzleIndexes>::value...> swizzle() {
return m_Vector;
}

#ifdef __SYCL_ACCESS_RETURN
#error "Undefine __SYCL_ACCESS_RETURN macro"
#endif
Expand Down
16 changes: 4 additions & 12 deletions sycl/test/basic_tests/vectors/swizzle.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
// RUN: %clangxx -fsycl %s -o %t_default.out
// RUN: %t_default.out

// FIXME: Everything should compile cleanly.
// RUN: %clangxx -fsycl -fsycl-device-only -DCHECK_ERRORS -fsyntax-only -Xclang -verify -Xclang -verify-ignore-unexpected=note,error %s

#include <sycl/vector.hpp>

int main() {
Expand All @@ -15,27 +12,22 @@ int main() {
// FIXME: Should be "4":
assert((sw + sw).lo()[0] == 2);

// FIXME: The below should compile.
#if CHECK_ERRORS
// expected-error-re@+1 {{no template named 'swizzle' in {{.*}}}}
assert(sw.swizzle<0>()[0] == 2);
// expected-error-re@+1 {{no template named 'swizzle' in {{.*}}}}
assert(sw.swizzle<1>()[0] == 3);

{
// expected-error-re@+1 {{no template named 'swizzle' in {{.*}}}}
auto tmp = sw.swizzle<1, 0>();
assert(tmp[0] == 3);
assert(tmp[1] == 2);
}

{
// expected-error-re@+1 {{no template named 'swizzle' in {{.*}}}}
auto tmp = (sw + sw).swizzle<1, 0>();
assert(tmp[0] == 6);
assert(tmp[1] == 4);

// FIXME: Should be "6" and "4", respectively.
assert(tmp[0] == 3);
assert(tmp[1] == 2);
}
#endif

return 0;
}
Loading