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

Fix MaskBool initialization on SSE #300

Merged
merged 1 commit into from
Sep 3, 2021
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
2 changes: 1 addition & 1 deletion Vc/sse/mask.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ template <typename T> class Mask<T, VectorAbi::Sse>
friend reference;
static Vc_INTRINSIC Vc_PURE value_type get(const Mask &m, int i) noexcept
{
return MaskBool(m.d.m(i));
return m.toInt() & (1 << i);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess that works. Looking at the previous implementation, it aliased the vector register by a T array and then accessed at i. That is what's happening in m.d.m(i). So that might fore storing the register to memory. Your solution probably stays within the registers and might even be more efficient. AVX also uses your implementation.

}
template <typename U>
static Vc_INTRINSIC void set(Mask &m, int i,
Expand Down
11 changes: 11 additions & 0 deletions tests/mask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,17 @@ TEST_TYPES(V, testCompareOperators, AllVectors) /*{{{*/
VERIFY(!(k2 != k2)) << k << k2;
}
}

TEST_TYPES(V, testMaskDefined, AllVectors)
{
V a(1);
V b(2);
auto r = a < b;
auto s = a > b;
VERIFY(r[0] == true);
VERIFY(s[0] == false);
}

/*}}}*/

// vim: foldmethod=marker