Skip to content

Commit

Permalink
cpusupport: detect a missing _mm_loadu_si64
Browse files Browse the repository at this point in the history
Old compilers (clang before 2016, gcc before 2019) didn't implement the
_mm_loadu_si64() function.

As for the compiler flags: in some cases, all we need is
    -maes -DBROKEN_MM_LOADU_SI64
but sometimes we might need
    -maes -Wno-cast-align -DBROKEN_MM_LOADU_SI64
or
    -maes -Wno-cast-align -Wno-cast-qual -DBROKEN_MM_LOADU_SI64
or even
    -maes -Wno-cast-align -Wno-cast-qual -Wno-missing-prototypes -DBROKEN_MM_LOADU_SI64

However, the more tests we add to cpusupport.sh, the longer it takes.
I figured that since this is only relevant to old compilers, we might as
well give it the full set of flags, so that newer compilers don't spend
time checking it.
  • Loading branch information
gperciva committed Feb 23, 2021
1 parent 59d05dc commit 4349f54
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 6 additions & 1 deletion libcperciva/cpusupport/Build/cpusupport-X86-AESNI.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ main(void)
uint8_t a[16];

x = load_128(a);
y = _mm_aesenc_si128(x, x);
#ifdef BROKEN_MM_LOADU_SI64
y = _mm_loadu_si128(a);
#else
y = _mm_loadu_si64(a);
#endif
y = _mm_aesenc_si128(x, y);
_mm_storeu_si128((__m128i *)&a[0], y);
return (a[0]);
}
4 changes: 3 additions & 1 deletion libcperciva/cpusupport/Build/cpusupport.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ feature X86 CPUID_COUNT ""
feature X86 AESNI "" "-maes" \
"-maes -Wno-cast-align" \
"-maes -Wno-missing-prototypes -Wno-cast-qual" \
"-maes -Wno-missing-prototypes -Wno-cast-qual -Wno-cast-align"
"-maes -Wno-missing-prototypes -Wno-cast-qual -Wno-cast-align" \
"-maes -Wno-missing-prototypes -Wno-cast-qual -Wno-cast-align \
-DBROKEN_MM_LOADU_SI64"
feature X86 CRC32_64 "" "-msse4.2" \
"-msse4.2 -Wno-cast-align" \
"-msse4.2 -Wno-cast-align -fno-strict-aliasing" \
Expand Down

0 comments on commit 4349f54

Please sign in to comment.