Bug 10077

Summary: gcc -msse2 generates movd to move dwords between xmm regs
Product: gcc Reporter: douze
Component: targetAssignee: Jan Hubicka <hubicka>
Status: RESOLVED FIXED    
Severity: critical CC: aj, aj, gcc-bugs
Priority: P2    
Version: 3.2.2   
Target Milestone: ---   
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed:
Attachments: gcc_bug.i

Description douze 2003-03-14 08:16:00 UTC
The bug appears when I compile a function with many variables. GCC then uses xmm registers as 32-bit scalar integer registers.

When it has to move data with an xmm register involved, it generates a movd instruction, which doesn't work (movss might work better). Although there is sse2 assembly in my code, I don't think it comes from there. 

The assembler used is GNU assembler version 2.11.92.0.10 (i486-suse-linux) using BFD version 2.11.92.0.10 20011021 (SuSE)


Notes added by Andreas Jaeger:
This bug can also be reproduced with GCC 3.3 from 20030313 (just verified).  The produced code contains then:
        movd    %xmm7, %xmm3
which is invalid.

This bug seems to be fixed in GCC 3.4.

Release:
gcc 3.2.2 on x86

Environment:
Linux 2.4.18

How-To-Repeat:
Compile the code with 

gcc -c gcc_bug.i -msse2 -O3
Comment 1 douze 2003-03-14 08:16:00 UTC
Fix:
replace movd with movss in the .s file
Comment 2 Andreas Jaeger 2003-03-14 10:31:02 UTC
From: Andreas Jaeger <aj@suse.de>
To: douze@enseeiht.fr
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: target/10077: gcc -msse2 generates movd to move dwords between
 xmm regs
Date: Fri, 14 Mar 2003 10:31:02 +0100

 douze@enseeiht.fr writes:
 
 >>Number:         10077
 >>Category:       target
 >>Synopsis:       gcc -msse2 generates movd to move dwords between xmm regs
 >>Confidential:   no
 >>Severity:       critical
 >>Priority:       medium
 >>Responsible:    unassigned
 >>State:          open
 >>Class:          sw-bug
 >>Submitter-Id:   net
 >>Arrival-Date:   Fri Mar 14 08:16:00 UTC 2003
 >>Closed-Date:
 >>Last-Modified:
 >>Originator:     douze@enseeiht.fr
 >>Release:        gcc 3.2.2 on x86
 >>Organization:
 >>Environment:
 > Linux 2.4.18
 >>Description:
 > The bug appears when I compile a function with many variables. GCC then uses xmm registers as 32-bit scalar integer registers.
 >
 > When it has to move data with an xmm register involved, it generates a movd instruction, which doesn't work (movss might work better). Although there is sse2 assembly in my code, I don't think it comes from there. 
 >
 > The assembler used is GNU assembler version 2.11.92.0.10 (i486-suse-linux) using BFD version 2.11.92.0.10 20011021 (SuSE)
 >>How-To-Repeat:
 > Compile the code with 
 >
 > gcc -c gcc_bug.i -msse2 -O3
 >>Fix:
 > replace movd with movss in the .s file
 
 Which instruction is generated in this case?  I only see one movd
 generated (with not exactly the same compiler) and that one looks fine
 to me (and might even come from your inline assembler).
 
 Please tell us a bit more why the generated code is wrong, 
 
 Andreas
 -- 
  Andreas Jaeger
   SuSE Labs aj@suse.de
    private aj@arthur.inka.de
     http://www.suse.de/~aj
Comment 3 Andreas Jaeger 2003-03-14 12:05:46 UTC
Responsible-Changed-From-To: unassigned->hubicka
Responsible-Changed-Why: SSE2 expert ;-)
Comment 4 Wolfgang Bangerth 2003-03-14 15:12:08 UTC
State-Changed-From-To: open->analyzed
State-Changed-Why: I can confirm this: it leads to an assembler error with
    3.2.2 and 3.3, but not with 3.4:
    
    g/x> /home/bangerth/bin/gcc-3.3-pre/bin/gcc -c gcc_bug.i -msse2 -O3
    /tmp/ccn5g6XV.s: Assembler messages:
    /tmp/ccn5g6XV.s:127: Error: suffix or operands invalid for `movd'
    
    I leave it to others to find out where this problem comes
    from. Since mainline compiles and assembles this file
    just fine, this seems indeed like a problem in the compiler.
    
    The instruction in question is this one:
    	movd	%xmm7, %xmm3
    
    W.
Comment 5 Jan Hubicka 2003-04-07 20:14:17 UTC
From: hubicka@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: target/10077
Date: 7 Apr 2003 20:14:17 -0000

 CVSROOT:	/cvs/gcc
 Module name:	gcc
 Branch: 	gcc-3_3-branch
 Changes by:	hubicka@gcc.gnu.org	2003-04-07 20:14:17
 
 Modified files:
 	gcc            : ChangeLog 
 	gcc/config/i386: i386.md 
 
 Log message:
 	PR target/10077
 	* i386.md (movsi_1):  Fix SSEMOV alternative.
 
 Patches:
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.16114.2.411&r2=1.16114.2.412
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/i386/i386.md.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.404.2.13&r2=1.404.2.14
 

Comment 6 Jan Hubicka 2003-04-07 20:22:51 UTC
From: hubicka@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: target/10077
Date: 7 Apr 2003 20:22:51 -0000

 CVSROOT:	/cvs/gcc
 Module name:	gcc
 Changes by:	hubicka@gcc.gnu.org	2003-04-07 20:22:51
 
 Modified files:
 	gcc            : ChangeLog 
 	gcc/config/i386: i386.md 
 
 Log message:
 	PR target/10077
 	* i386.md (movsi_1, movsi_nointerunit_1):  Fix SSEMOV alternative.
 
 Patches:
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=1.17355&r2=1.17356
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/i386/i386.md.diff?cvsroot=gcc&r1=1.453&r2=1.454
 
Comment 7 Jan Hubicka 2003-04-14 14:13:38 UTC
State-Changed-From-To: analyzed->closed
State-Changed-Why: Fixed.