[libcxx-commits] [PATCH] D144364: [libcxx] <experimental/simd> Added internal storage type, constructors, subscript operators of class simd/simd_mask and related tests

Yin Zhang via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Sun Jul 23 19:14:11 PDT 2023


Joy12138 added inline comments.


================
Comment at: libcxx/include/experimental/__simd/vec_ext.h:30-34
+#  if defined(_LIBCPP_COMPILER_CLANG_BASED)
+  _Tp __data __attribute__((vector_size(sizeof(_Tp) * _Np)));
+#  else
+  _Tp __data __attribute__((vector_size(std::__bit_ceil((sizeof(_Tp) * _Np)))));
+#  endif
----------------
philnik wrote:
> Why the conditional? Does this somehow help optimizations?
`libcxx CI - GCC 12 / C++latest` gives errors with vector size that is not a power of two:

```
/home/libcxx-builder/.buildkite-agent/builds/google-libcxx-builder-8484195cd0ed-1/llvm-project/libcxx-ci/build/generic-gcc/include/c++/v1/experimental/__simd/vec_ext.h:30:7: error: number of vector components 3 not a power of two
   30 |   _Tp __data __attribute__((vector_size(sizeof(_Tp) * _Np)));
      |       ^~~~~~
```

It seems GCC 12 doesn't support non-power-of-two vector lengths. So I added the conditional.


================
Comment at: libcxx/test/std/experimental/simd/test_utils.h:53-58
+template <class T>
+struct is_simd_reference : std::false_type {};
+
+template <class T, class S, class V>
+struct is_simd_reference<ex::__reference<T, S, V>> : std::true_type {};
+
----------------
philnik wrote:
> This isn't portable, and I don't really see the point. Nobody cares what the type is named internally.
Then the type check of reference in the `simd[_mask]_alias.pass.cpp` is also unnecessary, right? Can I directly remove them?



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D144364/new/

https://reviews.llvm.org/D144364



More information about the libcxx-commits mailing list