Skip to content

Commit

Permalink
suppress a strict aliasing warning; the original author was very clea…
Browse files Browse the repository at this point in the history
…r about the nature of the problematic code
  • Loading branch information
chrismamo1 committed Aug 12, 2017
1 parent efa50da commit f9b51d7
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions arch/dotproductavx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ double DotProductAVX(const double* u, const double* v, int n) {
// instruction, as that introduces a 70 cycle delay. All this casting is to
// fool the intrinsics into thinking we are extracting the bottom int64.
auto cast_sum = _mm256_castpd_si256(sum);
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstrict-aliasing")
*(reinterpret_cast<int64_t*>(&result)) =
#if defined(_WIN32) || defined(__i386__)
// This is a very simple workaround that is activated
Expand All @@ -100,6 +102,7 @@ double DotProductAVX(const double* u, const double* v, int n) {
_mm256_extract_epi64(cast_sum, 0)
#endif
;
#pragma GCC diagnostic pop
while (offset < n) {
result += u[offset] * v[offset];
++offset;
Expand Down

0 comments on commit f9b51d7

Please sign in to comment.