public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/34256]  New: mmx and movd/movq on x86_64
@ 2007-11-28  1:15 dean at arctic dot org
  2007-11-28  1:44 ` [Bug target/34256] " dean at arctic dot org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: dean at arctic dot org @ 2007-11-28  1:15 UTC (permalink / raw)
  To: gcc-bugs

gcc seems allergic to movq in the context of mmx:

% cat movq.c
#include <inttypes.h>
#include <mmintrin.h>

__m64 x;
__m64 y;

uint64_t foo(__m64 m) {
  return _mm_cvtm64_si64(_mm_add_pi32(x, y));
}
% gcc -g -O3 -Wall -std=gnu99   -c -o movq.o movq.c
% objdump -dr movq.o

movq.o:     file format elf64-x86-64

Disassembly of section .text:

0000000000000000 <foo>:
   0:   48 8b 05 00 00 00 00    mov    0(%rip),%rax        # 7 <foo+0x7>
                        3: R_X86_64_PC32        x+0xfffffffffffffffc
   7:   48 89 44 24 f8          mov    %rax,0xfffffffffffffff8(%rsp)
   c:   0f 6f 44 24 f8          movq   0xfffffffffffffff8(%rsp),%mm0
  11:   0f fe 05 00 00 00 00    paddd  0(%rip),%mm0        # 18 <foo+0x18>
                        14: R_X86_64_PC32       y+0xfffffffffffffffc
  18:   0f 7f 44 24 f8          movq   %mm0,0xfffffffffffffff8(%rsp)
  1d:   48 8b 44 24 f8          mov    0xfffffffffffffff8(%rsp),%rax
  22:   c3                      retq

the load of x should use "movq m64,mm".  this is true in i386 targets as well.

the transfer of %mm0 to %rax has the option of "movq %mm0,%rax" on x86_64, but
should possibly be passed through memory depending on -mtune= settings:

for intel core2 always use movq directly between the registers, no matter which
direction.

for AMD k8 family 15 always pass through mem

for AMD k8 family 16+, for gpr->xmm/mmx pass through memory and for xmm/mmx ->
gpr always use movd/movq direct between the registers.

-dean

p.s. gcc -v
Using built-in specs.
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc/configure --prefix=/home/odo/gcc --disable-multilib
--disable-biarch x86_64-unknown-linux-gnu --enable-languages=c
Thread model: posix
gcc version 4.3.0 20071128 (experimental) (GCC)


-- 
           Summary: mmx and movd/movq on x86_64
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: dean at arctic dot org
 GCC build triplet: x86_64-unknown-linux-gnu
  GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34256


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug target/34256] mmx and movd/movq on x86_64
  2007-11-28  1:15 [Bug target/34256] New: mmx and movd/movq on x86_64 dean at arctic dot org
@ 2007-11-28  1:44 ` dean at arctic dot org
  2007-11-28 12:45 ` ubizjak at gmail dot com
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: dean at arctic dot org @ 2007-11-28  1:44 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from dean at arctic dot org  2007-11-28 01:43 -------
this appears to be a regression between gcc 4.1.x and 4.2.x.  i had to switch
the intrinsic to _mm_cvtsi64_si64x but it otherwise generates the same code on
4.3.x...

ubuntu 4.1.2:

% objdump -dr movq.o

movq.o:     file format elf64-x86-64

Disassembly of section .text:

0000000000000000 <foo>:
   0:   0f 6f 05 00 00 00 00    movq   0(%rip),%mm0        # 7 <foo+0x7>
                        3: R_X86_64_PC32        x+0xfffffffffffffffc
   7:   0f fe 05 00 00 00 00    paddd  0(%rip),%mm0        # e <foo+0xe>
                        a: R_X86_64_PC32        y+0xfffffffffffffffc
   e:   48 0f 7e c0             movd   %mm0,%rax
  12:   c3                      retq

and 4.2.1:

movq.o:     file format elf64-x86-64

Disassembly of section .text:

0000000000000000 <foo>:
   0:   48 8b 05 00 00 00 00    mov    0x0(%rip),%rax        # 7 <foo+0x7>
                        3: R_X86_64_PC32        x+0xfffffffffffffffc
   7:   48 89 44 24 f8          mov    %rax,-0x8(%rsp)
   c:   0f 6f 44 24 f8          movq   -0x8(%rsp),%mm0
  11:   0f fe 05 00 00 00 00    paddd  0x0(%rip),%mm0        # 18 <foo+0x18>
                        14: R_X86_64_PC32       y+0xfffffffffffffffc
  18:   0f 7f 44 24 f8          movq   %mm0,-0x8(%rsp)
  1d:   48 8b 44 24 f8          mov    -0x8(%rsp),%rax
  22:   c3                      retq


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34256


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug target/34256] mmx and movd/movq on x86_64
  2007-11-28  1:15 [Bug target/34256] New: mmx and movd/movq on x86_64 dean at arctic dot org
  2007-11-28  1:44 ` [Bug target/34256] " dean at arctic dot org
@ 2007-11-28 12:45 ` ubizjak at gmail dot com
  2007-11-28 12:46 ` ubizjak at gmail dot com
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: ubizjak at gmail dot com @ 2007-11-28 12:45 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from ubizjak at gmail dot com  2007-11-28 12:45 -------
Created an attachment (id=14653)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=14653&action=view)
Patch to adjust mmx move instructions

It looks that mmx move instructions need some tuning.  Attached patch fixes
your problems and generates (-march=core2):

foo:
.LFB4:
        movq    x(%rip), %mm0
        paddd   y(%rip), %mm0
        movd    %mm0, %rax
        ret

Since these RA adjustments are very fragile, this patch is not appropriate for
stage3.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34256


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug target/34256] mmx and movd/movq on x86_64
  2007-11-28  1:15 [Bug target/34256] New: mmx and movd/movq on x86_64 dean at arctic dot org
  2007-11-28  1:44 ` [Bug target/34256] " dean at arctic dot org
  2007-11-28 12:45 ` ubizjak at gmail dot com
@ 2007-11-28 12:46 ` ubizjak at gmail dot com
  2007-12-10  8:40 ` ubizjak at gmail dot com
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: ubizjak at gmail dot com @ 2007-11-28 12:46 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from ubizjak at gmail dot com  2007-11-28 12:46 -------
Confirmed.


-- 

ubizjak at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
           Keywords|                            |patch
   Last reconfirmed|0000-00-00 00:00:00         |2007-11-28 12:46:37
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34256


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug target/34256] mmx and movd/movq on x86_64
  2007-11-28  1:15 [Bug target/34256] New: mmx and movd/movq on x86_64 dean at arctic dot org
                   ` (2 preceding siblings ...)
  2007-11-28 12:46 ` ubizjak at gmail dot com
@ 2007-12-10  8:40 ` ubizjak at gmail dot com
  2008-02-23 15:25 ` uros at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: ubizjak at gmail dot com @ 2007-12-10  8:40 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from ubizjak at gmail dot com  2007-12-10 08:40 -------


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


-- 

ubizjak at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |DUPLICATE


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34256


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug target/34256] mmx and movd/movq on x86_64
  2007-11-28  1:15 [Bug target/34256] New: mmx and movd/movq on x86_64 dean at arctic dot org
                   ` (3 preceding siblings ...)
  2007-12-10  8:40 ` ubizjak at gmail dot com
@ 2008-02-23 15:25 ` uros at gcc dot gnu dot org
  2008-11-16  0:09 ` howarth at nitro dot med dot uc dot edu
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: uros at gcc dot gnu dot org @ 2008-02-23 15:25 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from uros at gcc dot gnu dot org  2008-02-23 15:24 -------
Subject: Bug 34256

Author: uros
Date: Sat Feb 23 15:24:02 2008
New Revision: 132572

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=132572
Log:
        PR target/22076
        PR target/34256

        * config/i386/mmx.md (*mov<mode>_internal_rex64): Use "!y" to
        prevent reload from using MMX registers.
        (*mov<mode>_internal): Ditto.
        (*movv2sf_internal_rex64): Ditto.
        (*movv2sf_internal): Ditto.

testsuite/ChangeLog:

        PR target/22076
        PR target/34256
        * gcc.target/i386/pr22076.c: New test.
        * gcc.target/i386/pr34256.c: New test.
        * gcc.target/i386/vecinit-5.c: New test.
        * gcc.target/i386/vecinit-6.c: New test.
        * gcc.target/i386/vecinit-[1-4].c: Check that no MMX register is used.

        * g++.dg/compat/struct-layout-1.h: Do not include <mmintrin.h> and
        <xmmintrin.h>, define __m64 and __m128 directly.
        * g++.dg/compat/struct-layout-1_generate.c: Add -mno-mmx for x86.

Added:
    trunk/gcc/testsuite/gcc.target/i386/pr22076.c
    trunk/gcc/testsuite/gcc.target/i386/pr34256.c
    trunk/gcc/testsuite/gcc.target/i386/vecinit-5.c
    trunk/gcc/testsuite/gcc.target/i386/vecinit-6.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/i386/mmx.md
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/g++.dg/compat/struct-layout-1.h
    trunk/gcc/testsuite/g++.dg/compat/struct-layout-1_generate.c
    trunk/gcc/testsuite/gcc.target/i386/vecinit-1.c
    trunk/gcc/testsuite/gcc.target/i386/vecinit-2.c
    trunk/gcc/testsuite/gcc.target/i386/vecinit-3.c
    trunk/gcc/testsuite/gcc.target/i386/vecinit-4.c


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34256


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug target/34256] mmx and movd/movq on x86_64
  2007-11-28  1:15 [Bug target/34256] New: mmx and movd/movq on x86_64 dean at arctic dot org
                   ` (4 preceding siblings ...)
  2008-02-23 15:25 ` uros at gcc dot gnu dot org
@ 2008-11-16  0:09 ` howarth at nitro dot med dot uc dot edu
  2008-11-16  0:10 ` howarth at nitro dot med dot uc dot edu
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: howarth at nitro dot med dot uc dot edu @ 2008-11-16  0:09 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from howarth at nitro dot med dot uc dot edu  2008-11-16 00:07 -------
The gcc.target/i386/pr34256.c test case fails on i686-apple-darwin9 at -m64 as
follows...

Executing on host:
/sw/src/fink.build/gcc44-4.3.999-20081115/darwin_objdir/gcc/xgcc
-B/sw/src/fink.build/gcc44-4.3.999-20081115/darwin_objdi
r/gcc/
/sw/src/fink.build/gcc44-4.3.999-20081115/gcc-4.4-20081115/gcc/testsuite/gcc.target/i386/pr34256.c
  -O2 -march=core2 -S  -m64 -o pr3
4256.s    (timeout = 300)
PASS: gcc.target/i386/pr34256.c (test for excess errors)
FAIL: gcc.target/i386/pr34256.c scan-assembler-times mov 4


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34256


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug target/34256] mmx and movd/movq on x86_64
  2007-11-28  1:15 [Bug target/34256] New: mmx and movd/movq on x86_64 dean at arctic dot org
                   ` (5 preceding siblings ...)
  2008-11-16  0:09 ` howarth at nitro dot med dot uc dot edu
@ 2008-11-16  0:10 ` howarth at nitro dot med dot uc dot edu
  2008-11-17  0:36 ` howarth at nitro dot med dot uc dot edu
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: howarth at nitro dot med dot uc dot edu @ 2008-11-16  0:10 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from howarth at nitro dot med dot uc dot edu  2008-11-16 00:09 -------
Created an attachment (id=16691)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=16691&action=view)
assembly file generated for gcc.target/i386/pr34256.c at -m64 on
i686-apple-darwin9


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34256


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug target/34256] mmx and movd/movq on x86_64
  2007-11-28  1:15 [Bug target/34256] New: mmx and movd/movq on x86_64 dean at arctic dot org
                   ` (6 preceding siblings ...)
  2008-11-16  0:10 ` howarth at nitro dot med dot uc dot edu
@ 2008-11-17  0:36 ` howarth at nitro dot med dot uc dot edu
  2008-11-17  0:39 ` howarth at nitro dot med dot uc dot edu
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: howarth at nitro dot med dot uc dot edu @ 2008-11-17  0:36 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from howarth at nitro dot med dot uc dot edu  2008-11-17 00:34 -------
The gcc.target/i386/pr34256.c test case is still failing as...

Executing on host:
/sw/src/fink.build/gcc44-4.3.999-20081116/darwin_objdir/gcc/xgcc
-B/sw/src/fink.build/gcc44-4.3.999-20081116/darwin_objdir/gcc/
/sw/src/fink.build/gcc44-4.3.999-20081116/gcc-4.4-20081116/gcc/testsuite/gcc.target/i386/pr34256.c
  -O2 -fomit-frame-pointer -march=core2 -S  -m64 -o pr34256.s    (timeout =
300)
PASS: gcc.target/i386/pr34256.c (test for excess errors)
FAIL: gcc.target/i386/pr34256.c scan-assembler-times mov 4
UNSUPPORTED: gcc.target/i386/pr34312.c
UNSUPPORTED: gcc.target/i386/pr34522.c
UNSUPPORTED: gcc.target/i386/pr35083.c


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34256


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug target/34256] mmx and movd/movq on x86_64
  2007-11-28  1:15 [Bug target/34256] New: mmx and movd/movq on x86_64 dean at arctic dot org
                   ` (7 preceding siblings ...)
  2008-11-17  0:36 ` howarth at nitro dot med dot uc dot edu
@ 2008-11-17  0:39 ` howarth at nitro dot med dot uc dot edu
  2008-12-13 18:39 ` howarth at nitro dot med dot uc dot edu
  2008-12-13 19:30 ` ubizjak at gmail dot com
  10 siblings, 0 replies; 12+ messages in thread
From: howarth at nitro dot med dot uc dot edu @ 2008-11-17  0:39 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from howarth at nitro dot med dot uc dot edu  2008-11-17 00:37 -------
Created an attachment (id=16704)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=16704&action=view)
assembly file for gcc.target/i386/pr34256.c at -m64 on i686-apple-darwin9 with
-fomit-frame-pointer


-- 

howarth at nitro dot med dot uc dot edu changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #16691|0                           |1
        is obsolete|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34256


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug target/34256] mmx and movd/movq on x86_64
  2007-11-28  1:15 [Bug target/34256] New: mmx and movd/movq on x86_64 dean at arctic dot org
                   ` (8 preceding siblings ...)
  2008-11-17  0:39 ` howarth at nitro dot med dot uc dot edu
@ 2008-12-13 18:39 ` howarth at nitro dot med dot uc dot edu
  2008-12-13 19:30 ` ubizjak at gmail dot com
  10 siblings, 0 replies; 12+ messages in thread
From: howarth at nitro dot med dot uc dot edu @ 2008-12-13 18:39 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from howarth at nitro dot med dot uc dot edu  2008-12-13 18:38 -------
On i686-apple-darwin9, I have been using...

Using built-in specs.
Target: i686-apple-darwin9
Configured with: ../gcc-4.4-20081213/configure --prefix=/sw
--prefix=/sw/lib/gcc4.4 --mandir=/sw/share/man --infodir=/sw/share/info
--enable-languages=c,c++,fortran,objc,java --with-gmp=/sw
--with-libiconv-prefix=/sw --with-ppl=/sw --with-cloog=/sw --with-system-zlib
--x-includes=/usr/X11R6/include --x-libraries=/usr/X11R6/lib --with-arch=nocona
--with-tune=generic --build=i686-apple-darwin9 --host=i686-apple-darwin9
--target=i686-apple-darwin9
Thread model: posix
gcc version 4.4.0 20081213 (experimental) (GCC) 

when the testsuite produces the failure...

FAIL: gcc.target/i386/pr34256.c scan-assembler-times mov 4


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34256


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug target/34256] mmx and movd/movq on x86_64
  2007-11-28  1:15 [Bug target/34256] New: mmx and movd/movq on x86_64 dean at arctic dot org
                   ` (9 preceding siblings ...)
  2008-12-13 18:39 ` howarth at nitro dot med dot uc dot edu
@ 2008-12-13 19:30 ` ubizjak at gmail dot com
  10 siblings, 0 replies; 12+ messages in thread
From: ubizjak at gmail dot com @ 2008-12-13 19:30 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #11 from ubizjak at gmail dot com  2008-12-13 19:29 -------
(In reply to comment #10)

> FAIL: gcc.target/i386/pr34256.c scan-assembler-times mov 4

PR 37364


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34256


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2008-12-13 19:30 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-11-28  1:15 [Bug target/34256] New: mmx and movd/movq on x86_64 dean at arctic dot org
2007-11-28  1:44 ` [Bug target/34256] " dean at arctic dot org
2007-11-28 12:45 ` ubizjak at gmail dot com
2007-11-28 12:46 ` ubizjak at gmail dot com
2007-12-10  8:40 ` ubizjak at gmail dot com
2008-02-23 15:25 ` uros at gcc dot gnu dot org
2008-11-16  0:09 ` howarth at nitro dot med dot uc dot edu
2008-11-16  0:10 ` howarth at nitro dot med dot uc dot edu
2008-11-17  0:36 ` howarth at nitro dot med dot uc dot edu
2008-11-17  0:39 ` howarth at nitro dot med dot uc dot edu
2008-12-13 18:39 ` howarth at nitro dot med dot uc dot edu
2008-12-13 19:30 ` ubizjak at gmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).