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-01 16:43

OH GOD WHAT DOES ALL THIS MEAN!!?

        .file   "sse.c"
        .text
        .p2align 4,,15
.globl qq
        .type   qq, @function
qq:
.LFB518:
        pand    %xmm1, %xmm0
        ret
.LFE518:
        .size   qq, .-qq
        .section        .eh_frame,"a",@progbits
.Lframe1:
        .long   .LECIE1-.LSCIE1
.LSCIE1:
        .long   0x0
        .byte   0x1
        .string "zR"
        .uleb128 0x1
        .sleb128 -8
        .byte   0x10
        .uleb128 0x1
        .byte   0x3
        .byte   0xc
        .uleb128 0x7
        .uleb128 0x8
        .byte   0x90
        .uleb128 0x1
        .align 8
.LECIE1:
.LSFDE1:
        .long   .LEFDE1-.LASFDE1
.LASFDE1:
        .long   .LASFDE1-.Lframe1
        .long   .LFB518
        .long   .LFE518-.LFB518
        .uleb128 0x0
        .align 8
.LEFDE1:
        .ident  "GCC: (GNU) 4.3.2"
        .section        .note.GNU-stack,"",@progbits

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