rweather / noise-c

Noise-C, a plain C implementation of the Noise protocol
MIT License
304 stars 86 forks source link

Compile without SIMD #21

Closed nazar-pc closed 7 years ago

nazar-pc commented 7 years ago

Is there a way to compile this library without SIMD with clang? I've tried following:

#undef __AVX2__
#undef __AVX__
#undef __SSE2__
#undef __SSSE3__

But it didn't help unfortunately.

Here is full list of functions that add SIMD instructions:

When mentioned functions are not used, SIMD instructions do not appear in compiled output.

nazar-pc commented 7 years ago

I found that this function is hardcoded to use SIMD in contrast to x86_64 version:

void
p448_bias (
    p448_t *a,
    int amt
) {
    uint32_t co1 = ((1ull<<28)-1)*amt, co2 = co1-amt;
    uint32x4_t lo = {co1,co1,co1,co1}, hi = {co2,co1,co1,co1};
    uint32x4_t *aa = (uint32x4_t*) a;
    aa[0] += lo;
    aa[1] += lo;
    aa[2] += hi;
    aa[3] += lo;
}