User account creation filtered due to spam.

Bug 42549 - Incorrect 3DNow! code generated
Summary: Incorrect 3DNow! code generated
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.5.0
: P3 normal
Target Milestone: 4.3.5
Assignee: Uroš Bizjak
URL: http://gcc.gnu.org/ml/gcc-patches/200...
Keywords: ssemmx
Depends on:
Blocks:
 
Reported: 2009-12-29 22:48 UTC by Debian GCC Maintainers
Modified: 2009-12-30 11:49 UTC (History)
1 user (show)

See Also:
Host:
Target: i486-linux-gnu
Build:
Known to work:
Known to fail:
Last reconfirmed: 2009-12-30 10:57:27


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Debian GCC Maintainers 2009-12-29 22:48:58 UTC
[forwarded from http://bugs.debian.org/560812]

With the following simple test file, the 3DNow! generated code is
incorrect, with final _m_pfsub generated as pfsubr %mm0,%mm0, thus
producing completely incorrect result.

seen with current branches and trunk.

  Matthias

*** main.c
#include <mm3dnow.h>

void Butterfly_3(__m64 *D,__m64 SC,unsigned int IStep,unsigned int Off)
{ __m64 T,T1,T2;

  T        = _m_pfmul(D[Off+1], SC);
  T1       = D[Off+0];
  D[Off+0] = _m_pfadd(T1, T);
  D[Off+1] = _m_pfsub(T1, T);
}

The command line is:

gcc -march=athlon -S -O3 main.c

The generated code is:

*** main.s
    .file    "main.c"
    .text
    .p2align 4,,15
.globl Butterfly_3
    .type    Butterfly_3, @function
Butterfly_3:
    pushl    %ebp
    movl    %esp, %ebp
    movl    8(%ebp), %edx
    movl    16(%ebp), %ecx
    leal    8(%edx,%ecx,8), %eax
    leal    (%edx,%ecx,8), %edx
    pfmul    (%eax), %mm0
    movq    (%edx), %mm1
    movq    %mm1, %mm2
    pfadd    %mm0, %mm2
    pfsubr    %mm0, %mm0
    movq    %mm2, (%edx)
    movq    %mm0, (%eax)
    leave
    ret
    .size    Butterfly_3, .-Butterfly_3
    .ident    "GCC: (Debian 4.4.2-4) 4.4.2"
    .section    .note.GNU-stack,"",@progbits
Comment 1 Uroš Bizjak 2009-12-30 10:57:27 UTC
Confirmed, I have a patch.
Comment 2 uros 2009-12-30 11:07:34 UTC
Subject: Bug 42549

Author: uros
Date: Wed Dec 30 11:07:12 2009
New Revision: 155519

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=155519
Log:
	PR target/42549
	* config/i386/mmx.md ("*mmx_subv2sf3): Fix insn operand number for
	alternative 1.

testsuite/ChangeLog:

	PR target/42549
	* gcc.target/i386/mmx-3dnow-check.h: New file.
	* gcc.target/i386/pr42549.c: New test.


Added:
    trunk/gcc/testsuite/gcc.target/i386/mmx-3dnow-check.h
    trunk/gcc/testsuite/gcc.target/i386/pr42549.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/i386/mmx.md
    trunk/gcc/testsuite/ChangeLog

Comment 3 uros 2009-12-30 11:35:14 UTC
Subject: Bug 42549

Author: uros
Date: Wed Dec 30 11:34:57 2009
New Revision: 155521

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=155521
Log:
	PR target/42549
	* config/i386/mmx.md (*mmx_subv2sf3): Fix insn operand number for
	alternative 1.

testsuite/ChangeLog:

	PR target/42549
	* gcc.target/i386/mmx-3dnow-check.h: New file.
	* gcc.target/i386/pr42549.c: New test.


Added:
    branches/gcc-4_4-branch/gcc/testsuite/gcc.target/i386/mmx-3dnow-check.h
    branches/gcc-4_4-branch/gcc/testsuite/gcc.target/i386/pr42549.c
Modified:
    branches/gcc-4_4-branch/gcc/ChangeLog
    branches/gcc-4_4-branch/gcc/config/i386/mmx.md
    branches/gcc-4_4-branch/gcc/testsuite/ChangeLog

Comment 4 uros 2009-12-30 11:47:44 UTC
Subject: Bug 42549

Author: uros
Date: Wed Dec 30 11:47:30 2009
New Revision: 155522

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=155522
Log:
	PR target/42549
	* config/i386/mmx.md (*mmx_subv2sf3): Fix insn operand number for
	alternative 1.

testsuite/ChangeLog:

	PR target/42549
	* gcc.target/i386/mmx-3dnow-check.h: New file.
	* gcc.target/i386/pr42549.c: New test.


Added:
    branches/gcc-4_3-branch/gcc/testsuite/gcc.target/i386/mmx-3dnow-check.h
    branches/gcc-4_3-branch/gcc/testsuite/gcc.target/i386/pr42549.c
Modified:
    branches/gcc-4_3-branch/gcc/ChangeLog
    branches/gcc-4_3-branch/gcc/config/i386/mmx.md
    branches/gcc-4_3-branch/gcc/testsuite/ChangeLog

Comment 5 Uroš Bizjak 2009-12-30 11:49:17 UTC
Fixed.