Search code examples
gccassemblyosx-lionmacportsavx

How to use AVX/pclmulqdq on Mac OS X


I am trying to compile a program that uses the pclmulqdq instruction present in new Intel processors. I've installed GCC 4.6 using macports but when I compile my program (which uses the intrinsic _mm_clmulepi64_si128), I get

/var/folders/ps/sfjmtgx5771_qbqnh4c9xclr0000gn/T//ccEAWWhd.s:16:no such
instruction: `pclmulqdq $0, %xmm0,%xmm1'

It seems that GCC is able to generate the correct assembly code from the instrinsic, but the assembler does not recognize the instruction.

I've installed binutils using macports, but the problem persists. How do I know which assembler gcc is using? The XCode assembler probably does not support it, but the binutils assembler should.


Solution

  • A simpler solution that fixed this problem for me was adding -Wa,-q to the compiler flags. From the man pages for as (version 1.38):

    -q

         Use the clang(1) integrated assembler instead of the GNU based system assembler.

    The -Wa part passes it from the compiler driver to the assembler, much like -Wl passes arguments to the linker.