Skip to content

Commit

Permalink
Fix compiler warning
Browse files Browse the repository at this point in the history
  • Loading branch information
Legrandin committed Nov 9, 2019
1 parent b360e8e commit 6fa1f56
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 14 deletions.
21 changes: 11 additions & 10 deletions compiler_opt.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ def compiler_is_gcc():

def compiler_supports_sse2():
source = """
#include <x86intrin.h>
#include <intrin.h>
int main(void)
{
__m128i r0;
Expand All @@ -275,12 +275,11 @@ def compiler_supports_sse2():
return mask;
}
"""
if test_compilation(source, extra_cc_options=['-msse2'], msg="SSE2(x86intrin.h)"):
return {'extra_cc_options': ['-msse2'], 'extra_macros': ['HAVE_X86INTRIN_H', 'USE_SSE2']}
if test_compilation(source, msg="SSE2(intrin.h)"):
return {'extra_cc_options': [], 'extra_macros': ['HAVE_INTRIN_H', 'USE_SSE2']}

source = """
#include <xmmintrin.h>
#include <emmintrin.h>
#include <x86intrin.h>
int main(void)
{
__m128i r0;
Expand All @@ -290,21 +289,23 @@ def compiler_supports_sse2():
return mask;
}
"""
if test_compilation(source, extra_cc_options=['-msse2'], msg="SSE2(emmintrin.h)"):
return {'extra_cc_options': ['-msse2'], 'extra_macros': ['HAVE_EMMINTRIN_H', 'USE_SSE2']}
if test_compilation(source, extra_cc_options=['-msse2'], msg="SSE2(x86intrin.h)"):
return {'extra_cc_options': ['-msse2'], 'extra_macros': ['HAVE_X86INTRIN_H', 'USE_SSE2']}

source = """
#include <intrin.h>
#include <xmmintrin.h>
#include <emmintrin.h>
int main(void)
{
__m128i r0;
int mask;
r0 = _mm_set1_epi32(0);
mask = _mm_movemask_epi8(r0);
return mask;
}
"""
if test_compilation(source, msg="SSE2(intrin.h)"):
return {'extra_cc_options': [], 'extra_macros': ['HAVE_INTRIN_H', 'USE_SSE2']}
if test_compilation(source, extra_cc_options=['-msse2'], msg="SSE2(emmintrin.h)"):
return {'extra_cc_options': ['-msse2'], 'extra_macros': ['HAVE_EMMINTRIN_H', 'USE_SSE2']}

return False

Expand Down
2 changes: 1 addition & 1 deletion src/AESNI.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ static uint32_t sub_rot(uint32_t w, unsigned idx /** round/Nk **/, enum SubType

assert((idx>=1) && (idx<=10));

x = _mm_set1_epi32(w); // { w, w, w, w }
x = _mm_set1_epi32((int)w); // { w, w, w, w }
y = _mm_set1_epi32(0);

switch (idx) {
Expand Down
9 changes: 7 additions & 2 deletions src/mont.c
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,13 @@ STATIC int mont_select(uint64_t *out, const uint64_t *a, const uint64_t *b, unsi

pairs = (unsigned)words / 2;
mask = (uint64_t)((cond != 0) - 1); /* 0 for a, 1s for b */

r0 = _mm_set1_epi64((__m64)mask);

#if SYSBITS == 64
r0 = _mm_set1_epi64x(mask);
#else
r0 = _mm_loadl_epi64((__m128i*)&mask);
r0 = _mm_unpacklo_epi64(r0, r0);
#endif
for (i=0; i<pairs; i++, a+=2, b+=2, out+=2) {
r1 = _mm_loadu_si128((__m128i const*)b);
r2 = _mm_loadu_si128((__m128i const*)a);
Expand Down
2 changes: 1 addition & 1 deletion src/test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ TAPPS:=tests_addmul128_32 tests_addmul128_64 tests_square_32 tests_square_64 tes
test_mont tests_mont_mult tests_ec_ws_64 tests_ec_ws_32

ifneq (,$(filter $(shell uname -m),x86_64 i386 i686))
CPPFLAGS += -DHAVE_X86INTRIN_H -DUSE_SSE2
CPPFLAGS += -DHAVE_X86INTRIN_H -DUSE_SSE2 -DHAVE_WMMINTRIN_H -DHAVE_TMMINTRIN_H
CFLAGS += -msse2
TAPPS += test_clmul
endif
Expand Down

0 comments on commit 6fa1f56

Please sign in to comment.