Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ldc.gccbuiltins_x86 are missing __builtin_ia32_pmullw128 #627

Closed
MartinNowak opened this issue Jun 10, 2014 · 5 comments
Closed

ldc.gccbuiltins_x86 are missing __builtin_ia32_pmullw128 #627

MartinNowak opened this issue Jun 10, 2014 · 5 comments

Comments

@MartinNowak
Copy link
Contributor

There is __builtin_ia32_pmulhw128 but no correspondig pmullw.
I tried to add the following declaration, but it results in a link error.

pragma(LDC_intrinsic, "llvm.x86.sse2.pmull.w")
    short8 __builtin_ia32_pmullw128(short8, short8)nothrow pure @safe;

function _Dmain: error: undefined reference to 'llvm.x86.sse2.pmull.w'

@dnadlinger
Copy link
Member

This means LLVM doesn't recognize the intrinsic at all. Usually, this happens if there is a natural way to express this in terms of LLVM IR vector operations. This specific intrinsic doesn't ring a bell with me, but maybe an option would be to use the inline IR facilities. http://clang.llvm.org/builtins.py also seems to indicate that there is possibly a rewrite.

@dnadlinger
Copy link
Member

Okay, Clang defines this in the library (lib/Headers/emmintrin.h) as

static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
_mm_mullo_epi16(__m128i __a, __m128i __b)
{
  return (__m128i)((__v8hi)__a * (__v8hi)__b);
}

So, the best way to implement this would probably be either directly using D vector ops, or using inline IR. See https://github.com/ldc-developers/druntime/blob/ldc/src/ldc/simd.di for an example of the latter.

@Safety0ff
Copy link

@dnadlinger
Copy link
Member

Thanks – don't know what happened there. ;)

redstar pushed a commit that referenced this issue Sep 27, 2014
Added core.sys.posix.sys.socket declarations for ARM.
@dnadlinger
Copy link
Member

Closing, since the solution seems to be to use vector type multiplication.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants