Skip to content

Commit

Permalink
MSVC: Reimplement rotated and reversed as workaround
Browse files Browse the repository at this point in the history
MSVC doesn't find the 2-argument shifted member function from inside the
rotated and reversed implementations. Moving the function definition
after the class template declaration only helps for some SimdArray
instantiations. The only fix that fully works is to avoid calling
shifted altogether. Therefore, this now uses store-load with MSVC.

Refs: gh-119
Signed-off-by: Matthias Kretz <kretz@kde.org>
  • Loading branch information
mattkretz committed Sep 20, 2016
1 parent 120435d commit a45a904
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions common/simdarray.h
Original file line number Diff line number Diff line change
Expand Up @@ -1181,6 +1181,19 @@ public:
amount += size();
}

#ifdef Vc_MSVC
// MSVC fails to find a SimdArray::shifted function with 2 arguments. So use store
// ->
// load to implement the function instead.
alignas(MemoryAlignment) T tmp[N + data0.size()];
data0.store(&tmp[0], Vc::Aligned);
data1.store(&tmp[data0.size()], Vc::Aligned);
data0.store(&tmp[N], Vc::Unaligned);
SimdArray r;
r.data0.load(&tmp[amount], Vc::Unaligned);
r.data1.load(&tmp[(amount + data0.size()) % size()], Vc::Unaligned);
return r;
#else
auto &&d0cvtd = simd_cast<storage_type1>(data0);
auto &&d1cvtd = simd_cast<storage_type0>(data1);
constexpr int size0 = storage_type0::size();
Expand All @@ -1206,6 +1219,7 @@ public:
simd_cast<storage_type1>(data0.shifted(amount - size1, d1cvtd))};
}
return *this;
#endif
}

// interleaveLow/-High {{{2
Expand Down Expand Up @@ -1247,9 +1261,19 @@ public:
return {simd_cast<storage_type0>(data1).reversed(),
simd_cast<storage_type1>(data0).reversed()};
} else {
#ifdef Vc_MSVC
// MSVC fails to find a SimdArray::shifted function with 2 arguments. So use
// store
// -> load to implement the function instead.
alignas(MemoryAlignment) T tmp[N];
data1.reversed().store(&tmp[0], Vc::Aligned);
data0.reversed().store(&tmp[data1.size()], Vc::Unaligned);
return SimdArray{&tmp[0], Vc::Aligned};
#else
return {data0.shifted(storage_type1::Size, data1).reversed(),
simd_cast<storage_type1>(data0.reversed().shifted(
storage_type0::Size - storage_type1::Size))};
#endif
}
}
///\copydoc Vector::sorted
Expand Down

0 comments on commit a45a904

Please sign in to comment.