Bug 25277 - missed optimization for simple mmx code.
Summary: missed optimization for simple mmx code.
Status: RESOLVED DUPLICATE of bug 14552
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.2.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: missed-optimization, ssemmx
Depends on: 14552 22076
Blocks:
  Show dependency treegraph
 
Reported: 2005-12-06 14:57 UTC by Pawel Sikora
Modified: 2008-03-08 07:29 UTC (History)
4 users (show)

See Also:
Host: i686-pld-linux
Target: i686-pld-linux
Build: i686-pld-linux
Known to work:
Known to fail: 4.1.2 4.2.0
Last reconfirmed: 2006-03-05 03:02:58


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Pawel Sikora 2005-12-06 14:57:04 UTC
#include <mmintrin.h>
__v8qi foo(const __v8qi x, const __v8qi y){return x+y;}
__v8qi bar(const __v8qi x, const __v8qi y){return __builtin_ia32_paddb(x,y);}

$ gcc tmp.c -S -O2 -mmmx

3.3.6 produces the same code for foo() and bar():

foo:    movq    4(%esp), %mm0
        paddb   12(%esp), %mm0
        movq    %mm0, (%eax)
        ret

bar:    movq    4(%esp), %mm0
        paddb   12(%esp), %mm0
        movq    %mm0, (%eax)
        ret

4.2.0 produces horrible code for foo():

foo:    pushl   %edi
        pushl   %esi
        pushl   %ebx
        subl    $24, %esp
        movq    %mm0, (%esp)
        movl    (%esp), %ebx
        movl    4(%esp), %esi
        movl    %ebx, %edi
        movq    %mm1, (%esp)
        movl    (%esp), %eax
        movl    4(%esp), %edx
        movl    %eax, %ecx
        movl    %esi, %ebx
        movl    %edi, %eax
        xorl    %ecx, %eax
        andl    $-2139062144, %eax
        andl    $2139062143, %ecx
        andl    $2139062143, %edi
        addl    %edi, %ecx
        xorl    %ecx, %eax
        pxor    %mm0, %mm0
        movq    %mm0, 16(%esp)
        movl    %eax, 16(%esp)
        movl    %esi, %ecx
        xorl    %edx, %ecx
        andl    $-2139062144, %ecx
        andl    $2139062143, %edx
        andl    $2139062143, %ebx
        addl    %ebx, %edx
        xorl    %edx, %ecx
        movl    16(%esp), %eax
        movl    %eax, 8(%esp)
        movl    %ecx, 12(%esp)
        movq    8(%esp), %mm0
        addl    $24, %esp
        popl    %ebx
        popl    %esi
        popl    %edi
        ret

bar:    paddb   %mm1, %mm0
        ret
Comment 1 Pawel Sikora 2005-12-06 15:02:00 UTC
(In reply to comment #0)

> $ gcc tmp.c -S -O2 -mmmx

fix: -S -O2 -mmmx -fomit-frame-pointer -mregparm=3
Comment 2 Andrew Pinski 2005-12-06 16:04:58 UTC
This is not fully a regression as this was on purpose change until emms was emmitted correctly.  Anyways this is very much related to PR 22076 and PR 14552
Comment 3 Pawel Sikora 2006-08-07 08:27:01 UTC
gcc-4.1.2-20060712:

foo:    subl    $36, %esp       #,
        movq    %mm0, (%esp)    # x,
        movl    %ebx, 24(%esp)  #,
        movl    (%esp), %ebx    #, x
        movl    %esi, 28(%esp)  #,
        movl    4(%esp), %esi   #, x
        movq    %mm1, (%esp)    # y,
        movl    (%esp), %eax    #, y
        pxor    %mm0, %mm0      #
        movl    %edi, 32(%esp)  #,
        movl    %ebx, %edi      # x, D.2268
        movl    4(%esp), %edx   #, y
        movl    %esi, %ebx      # x, D.2276
        movq    %mm0, 16(%esp)  #,
        movl    %eax, %ecx      # y, D.2269
        movl    %edi, %eax      # D.2268, tmp71
        andl    $2139062143, %edi       #, D.2268
        xorl    %ecx, %eax      # D.2269, tmp71
        andl    $2139062143, %ecx       #, D.2269
        andl    $2139062143, %ebx       #, D.2276
        addl    %edi, %ecx      # D.2268, tmp75
        andl    $-2139062144, %eax      #, tmp71
        movl    32(%esp), %edi  #,
        xorl    %ecx, %eax      # tmp75, tmp71
        movl    %esi, %ecx      # D.2276, tmp77
        movl    28(%esp), %esi  #,
        movl    %eax, 16(%esp)  # tmp71,
        xorl    %edx, %ecx      # D.2277, tmp77
        movl    16(%esp), %eax  #,
        andl    $2139062143, %edx       #, D.2277
        andl    $-2139062144, %ecx      #, tmp77
        addl    %ebx, %edx      # D.2276, tmp81
        movl    24(%esp), %ebx  #,
        xorl    %edx, %ecx      # tmp81, tmp77
        movl    %eax, 8(%esp)   #,
        movl    %ecx, 12(%esp)  # tmp77,
        movq    8(%esp), %mm0   #, <result>
        addl    $36, %esp       #,
        ret
Comment 4 Uroš Bizjak 2008-03-08 07:29:54 UTC
Duplicate of PR 14552.

*** This bug has been marked as a duplicate of 14552 ***