Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Fancy SSE instructions in gcc

Name: Anonymous 2008-12-01 16:11

Does anyone know if gcc can produce code that uses SSE?

This is the program I'm trying to compile with gcc -msse -msse2 -msse3 sse.c -S -O2 -o sse.S:
#include <xmmintrin.h>

__m128i qq(__m128i a,__m128i b){
    return a&b;
}


And here's what I'm getting
    .file    "sse.c"
    .text
    .p2align 4,,15
.globl _qq
    .def    _qq;    .scl    2;    .type    32;    .endef
_qq:
    pushl    %ebp
    pxor    %xmm2, %xmm2
    movl    %esp, %ebp
    subl    $56, %esp
    movdqa    %xmm0, -24(%ebp)
    movl    -24(%ebp), %eax
    movdqa    %xmm1, -40(%ebp)
    movl    -40(%ebp), %ecx
    movdqa    %xmm2, -56(%ebp)
    movl    -36(%ebp), %edx
    andl    %ecx, %eax
    movl    %eax, -56(%ebp)
    movl    -20(%ebp), %eax
    movl    -32(%ebp), %ecx
    andl    %edx, %eax
    movl    -28(%ebp), %edx
    movl    %eax, -52(%ebp)
    movl    -16(%ebp), %eax
    andl    %ecx, %eax
    movl    %eax, -48(%ebp)
    movl    -12(%ebp), %eax
    andl    %edx, %eax
    movl    %eax, -44(%ebp)
    movdqa    -56(%ebp), %xmm0
    leave
    ret


This is most definitely not what I'm expecting; this simple function can be implemented in five instructions, but gcc decides to ignore SSE and do anding manually.

Name: Anonymous 2008-12-02 8:48

>>19
           These switches enable or disable the use of built-in functions that allow direct access to the
           MMX, SSE, SSE2, SSE3 and 3Dnow extensions of the instruction set.

it says they enable or disable those builtin functions (http://gcc.gnu.org/onlinedocs/gcc/X86-Built_002din-Functions.html#X86-Built_002din-Functions), not that they make it automatically rewrite your code to use them.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List