Skip to content

Commit

Permalink
Better autodetect of AES support, in case of aggressive optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
Legrandin committed Dec 29, 2023
1 parent 51cd585 commit b408368
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions compiler_opt.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def compiler_has_intrin_h():
{
int a, b[4];
__cpuid(b, a);
return 0;
return a;
}
"""
return test_compilation(source, msg="intrin.h header")
Expand All @@ -154,7 +154,7 @@ def compiler_has_cpuid_h():
{
unsigned int eax, ebx, ecx, edx;
__get_cpuid(1, &eax, &ebx, &ecx, &edx);
return 0;
return eax;
}
"""
return test_compilation(source, msg="cpuid.h header")
Expand All @@ -163,11 +163,16 @@ def compiler_has_cpuid_h():
def compiler_supports_aesni():
source = """
#include <wmmintrin.h>
#include <string.h>
__m128i f(__m128i x, __m128i y) {
return _mm_aesenc_si128(x, y);
}
int main(void) {
return 0;
int ret;
__m128i x = _mm_setzero_si128();
x = f(x, x);
memcpy(&ret, &x, sizeof(ret));
return ret;
}
"""

Expand Down

0 comments on commit b408368

Please sign in to comment.