[libcxx-commits] [PATCH] D156225: [libcxx] <experimental/simd> Add broadcast constructor of class simd/simd_mask
Nikolas Klauser via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Aug 8 08:55:45 PDT 2023
philnik added inline comments.
================
Comment at: libcxx/include/experimental/__simd/utility.h:71
+ (!__is_vectorizable_v<_Up> && is_convertible_v<_Up, _Tp>) || is_same_v<_Up, int> ||
+ (is_same_v<_Up, unsigned int> && is_unsigned_v<_Tp>);
+
----------------
I'm pretty sure that `unsigned int` is indeed unsigned.
================
Comment at: libcxx/include/experimental/__simd/utility.h:60-65
+template <typename __From, typename __To, typename = void>
+struct __is_value_preserving_convertible : std::false_type {};
+
+template <typename __From, typename __To>
+struct __is_value_preserving_convertible<__From, __To, decltype(static_cast<__To>(std::declval<__From>()))>
+ : std::true_type {};
----------------
Joy12138 wrote:
> philnik wrote:
> > Isn't this just `is_constructible<__To, __From>`?
> I'm not sure if the current implementation is the same as `is_constructible`.
> I am also not sure if either of them can meet the requirements of the document: "every possible value of `From` can be represented with type `To`".
> Do you have any suggestion?
I think we have to do something a bit more weird for that. I think we basically have to check that they are integral and that `sizeof(From) >= sizeof(To) && is_signed_v<From> == is_signed_v<To>`. I'm not sure about floating point types, but there we probably want to do the same % `bfloat16` (but that's not relevant for now anyways).
Also, we probably want to make these variable templates instead of structs. Didn't notice that before.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D156225/new/
https://reviews.llvm.org/D156225
More information about the libcxx-commits
mailing list