Skip to content

Commit

Permalink
Use alternative scatter implementation for Visual Studio 22
Browse files Browse the repository at this point in the history
Fixes: VcDevel#308
Suggested-by: Bruno Manganelli <[email protected]>
  • Loading branch information
amadio committed Jun 13, 2022
1 parent 628f5c0 commit 5ed4be3
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions Vc/common/scatterimplementation.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@ Vc_ALWAYS_INLINE void executeScatter(BitScanLoopT,
typename V::MaskArgument mask)
{
size_t bits = mask.toInt();
#ifdef Vc_MSVC
while (bits) {
const int i = _bit_scan_forward(bits);
bits ^= (1 << i); // btr?
mem[indexes[i]] = v[i];
}
#else
while (Vc_IS_LIKELY(bits > 0)) {
size_t i, j;
asm("bsf %[bits],%[i]\n\t"
Expand All @@ -83,15 +90,7 @@ Vc_ALWAYS_INLINE void executeScatter(BitScanLoopT,
mem[indexes[i]] = v[i];
mem[indexes[j]] = v[j];
}

/* Alternative from Vc::SSE (0.7)
int bits = mask.toInt();
while (bits) {
const int i = _bit_scan_forward(bits);
bits ^= (1 << i); // btr?
mem[indexes[i]] = v[i];
}
*/
#endif
}

template <typename V, typename MT, typename IT>
Expand Down

0 comments on commit 5ed4be3

Please sign in to comment.