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 2:20

>>10
Whatever, bro. It's not working either way and documentation isn't helping much.

       -msse
       -mno-sse
       -msse2
       -mno-sse2
       -msse3
       -mno-sse3
       -m3dnow
       -mno-3dnow
           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.

           To have SSE/SSE2 instructions generated automatically from floating-point code, see -mfpmath=sse.


All I want is to make gcc generate and optimize code for me, so that I don't have to do that in assembler.

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