Bug 7842 - [REGRESSION] sparc code gen bug
Summary: [REGRESSION] sparc code gen bug
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 3.2
: P3 normal
Target Milestone: ---
Assignee: David S. Miller
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2002-09-05 13:36 UTC by Mattias Engdegård
Modified: 2003-07-25 17:33 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
sparcbug.c (189 bytes, application/octet-stream)
2003-05-21 15:17 UTC, Mattias Engdegård
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mattias Engdegård 2002-09-05 13:36:00 UTC
The tiny g() function in the attached testcase is miscompiled by gcc 3.2 (and 3.1, 3.0.4) with -O2 -mcpu=ultrasparc. The testcase returns nonzero if the bug is present.

This is a regression - the bug seems not to be present in gcc 2.95.3.

The code generated by 3.0.4 contains the instruction
    and %reg, -1, %reg
which is a no-op, but from inspection it looks like the compiler really wanted to AND with 0xffffffff. Gcc 3.{1,2} do not have this error but still generate wrong code.

The bug is especially evil because in certain contexts, it
may appear to work when single-stepping with a debugger. This depends on the register assignments, since the high 32 bits of local/input registers are trashed on cpu traps.

Release:
gcc-3.2

Environment:
Solaris 8 on SPARC
Comment 1 David S. Miller 2002-09-26 03:22:06 UTC
Responsible-Changed-From-To: unassigned->davem
Responsible-Changed-Why: I got it.
Comment 2 David S. Miller 2002-09-26 03:22:06 UTC
State-Changed-From-To: open->analyzed
State-Changed-Why: config/sparc/sparc.c:set_extends() is buggy.
Comment 3 David S. Miller 2002-09-26 03:27:15 UTC
State-Changed-From-To: analyzed->closed
State-Changed-Why: Fixed, see audit trail.
Comment 4 David S. Miller 2002-09-26 10:16:45 UTC
From: davem@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: target/7842
Date: 26 Sep 2002 10:16:45 -0000

 CVSROOT:	/cvs/gcc
 Module name:	gcc
 Changes by:	davem@gcc.gnu.org	2002-09-26 03:16:44
 
 Modified files:
 	gcc/testsuite  : ChangeLog 
 Added files:
 	gcc/testsuite/gcc.c-torture/execute: shiftdi.c 
 
 Log message:
 	2002-09-25  David S. Miller  <davem@redhat.com>
 	
 	PR target/7842
 	* gcc.c-torture/execute/shiftdi.c: New test.
 
 Patches:
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.2097&r2=1.2098
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.c-torture/execute/shiftdi.c.diff?cvsroot=gcc&r1=NONE&r2=1.1
 

Comment 5 David S. Miller 2002-09-26 10:18:06 UTC
From: davem@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: target/7842
Date: 26 Sep 2002 10:18:06 -0000

 CVSROOT:	/cvs/gcc
 Module name:	gcc
 Changes by:	davem@gcc.gnu.org	2002-09-26 03:18:06
 
 Modified files:
 	gcc            : ChangeLog 
 	gcc/config/sparc: sparc.c 
 
 Log message:
 	2002-09-25  David S. Miller  <davem@redhat.com>
 	
 	PR target/7842
 	* config/sparc/sparc.c (set_extends): SImode ASHIFT does not
 	extend.
 
 Patches:
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=1.15535&r2=1.15536
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/sparc/sparc.c.diff?cvsroot=gcc&r1=1.230&r2=1.231
 

Comment 6 David S. Miller 2002-09-26 10:19:11 UTC
From: davem@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: target/7842
Date: 26 Sep 2002 10:19:11 -0000

 CVSROOT:	/cvs/gcc
 Module name:	gcc
 Branch: 	gcc-3_2-branch
 Changes by:	davem@gcc.gnu.org	2002-09-26 03:19:11
 
 Modified files:
 	gcc/testsuite  : ChangeLog 
 Added files:
 	gcc/testsuite/gcc.c-torture/execute: shiftdi.c 
 
 Log message:
 	2002-09-25  David S. Miller  <davem@redhat.com>
 	
 	PR target/7842
 	* gcc.c-torture/execute/shiftdi.c: New test.
 
 Patches:
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.1672.2.166.2.12&r2=1.1672.2.166.2.13
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.c-torture/execute/shiftdi.c.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=NONE&r2=1.1.2.1
 

Comment 7 David S. Miller 2002-09-26 10:20:04 UTC
From: davem@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: target/7842
Date: 26 Sep 2002 10:20:04 -0000

 CVSROOT:	/cvs/gcc
 Module name:	gcc
 Branch: 	gcc-3_2-branch
 Changes by:	davem@gcc.gnu.org	2002-09-26 03:20:04
 
 Modified files:
 	gcc            : ChangeLog 
 	gcc/config/sparc: sparc.c 
 
 Log message:
 	2002-09-25  David S. Miller  <davem@redhat.com>
 	
 	PR target/7842
 	* config/sparc/sparc.c (set_extends): SImode ASHIFT does not
 	extend.
 
 Patches:
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.13152.2.657.2.53&r2=1.13152.2.657.2.54
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/sparc/sparc.c.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.185.2.23&r2=1.185.2.23.2.1