Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vector: add constructor taking an element reference #286

Merged
merged 3 commits into from
Sep 1, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 2 additions & 4 deletions Vc/avx/const.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,7 @@ namespace AVX
{
#ifdef Vc_IMPL_AVX2
#if defined Vc_ICC || defined Vc_MSVC
__m256i allone;
allone = _mm256_cmpeq_epi8(allone, allone);
__m256i allone = _mm256_set1_epi64x(~0);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we go with this for all compilers and remove the ifdefs? I think it should be optimal in all cases, no?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Depends. I read somewhere that sometimes generating the constant is faster than reading a value from static memory. So we would need to check the generated code whether ~0 is stored in the static data or computed. But then, you are the expert on such matter, so I take your recommendation ;)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's computed for the other compilers, and I think that's actually ok, because at most that takes a few cycles, so it's like loading from L1. Loading from memory can be fast, or not, depending on where you're loading from.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use this implementation on all compilers now, but in a separate PR: #299.

#else
auto allone = ~__m256i();
#endif
Expand All @@ -134,8 +133,7 @@ namespace AVX
{
#ifdef Vc_IMPL_AVX2
#if defined Vc_ICC || defined Vc_MSVC
__m256i allone;
allone = _mm256_cmpeq_epi8(allone, allone);
__m256i allone = _mm256_set1_epi64x(~0);
#else
auto allone = ~__m256i();
#endif
Expand Down
2 changes: 1 addition & 1 deletion Vc/common/subscript.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ struct IndexVectorSizeMatches<MinSize,

template <std::size_t MinSize, typename T, std::ptrdiff_t N>
struct IndexVectorSizeMatches<MinSize, Vc::Common::span<T, N>, false>
: public std::integral_constant<bool, (N == -1 || MinSize <= N)> {
: public std::integral_constant<bool, (N == -1 || static_cast<std::ptrdiff_t>(MinSize) <= N)> {
};
// SubscriptOperation {{{1
template <
Expand Down