Bug 9164 - [Alpha] improper code generation
Summary: [Alpha] improper code generation
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: unknown
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: missed-optimization
Depends on:
Blocks:
 
Reported: 2003-01-03 15:16 UTC by rf358197
Modified: 2003-07-25 17:33 UTC (History)
3 users (show)

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


Attachments
test1.c (265 bytes, application/octet-stream)
2003-05-21 15:17 UTC, rf358197
Details

Note You need to log in before you can comment on or make changes to this bug.
Description rf358197 2003-01-03 15:16:05 UTC
There is a problem with the compiler on the Alpha platform when doing comparisons between variables of different types long and int.  This bug was discovered through mozilla's bug database and I am not sure if anyone from the GCC camp knows about it?

Release:
unknown

Environment:
DEC Alpha - linux 2.4

How-To-Repeat:
Compile the test program and see the two comparisons which should give the same result give different results but only on an Alpha platform.
Comment 1 falk.hueffner 2003-01-07 08:44:56 UTC
From: Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
To: rf358197@ohiou.edu, gcc-gnats@gcc.gnu.org, gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org, nobody@gcc.gnu.org
Cc:  
Subject: Re: target/9164: Improper code generation on Alpha processors.
Date: 07 Jan 2003 08:44:56 +0100

 > There is a problem with the compiler on the Alpha platform when
 > doing comparisons between variables of different types long and int.
 > This bug was discovered through mozilla's bug database and I am not
 > sure if anyone from the GCC camp knows about it?
 
 > #define INT_MAX1 (((long)1 << (30))-1)
 > #define INT_MAX2 (1073741824-1)
 > 
 > int main()
 > {
 > 	int i = 1073741825;
 > 	long j = 1073741823;
 >    
 > 	printf ("%ld %ld\n", INT_MAX1, INT_MAX2);
 > 	printf ("%x %x\n", i, j);
 > 	printf ("%x %x\n", (unsigned int)((i)+j), 2 * j);
 >    
 > 	if ((unsigned int)((i)+j) <= 2 * INT_MAX1) 
 > 		printf ("doh1\n");
 > 	if ((unsigned int)((i)+j) <= 2 * INT_MAX2)
 > 		printf ("doh2\n");
 > 	
 > 	exit(1);
 > }
 
 Hmm, weird one. Here's a slightly smaller test case:
 
 int main(void) {
     long j = 1073741823L;
     if ((unsigned int)(1073741825L + j) < 0L)
 	puts("bad");
     else
 	puts("good");
 }
 
 Looks like the intermediate result gets 32-bit sign extended
 erraneously.
 
 -- 
 	Falk

Comment 2 Richard Henderson 2003-03-16 19:43:53 UTC
From: rth@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: target/9164
Date: 16 Mar 2003 19:43:53 -0000

 CVSROOT:	/cvs/gcc
 Module name:	gcc
 Changes by:	rth@gcc.gnu.org	2003-03-16 19:43:53
 
 Modified files:
 	gcc            : ChangeLog tree.c 
 	gcc/testsuite  : ChangeLog 
 Added files:
 	gcc/testsuite/gcc.c-torture/execute: 20030316-1.c 
 
 Log message:
 	PR target/9164
 	* tree.c (get_narrower): For extensions with unchanged bit number,
 	return the unsignedness of the outer mode.
 	
 	* gcc.c-torture/execute/20030316-1.c: New test case.
 
 Patches:
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=1.17102&r2=1.17103
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree.c.diff?cvsroot=gcc&r1=1.289&r2=1.290
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.2512&r2=1.2513
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.c-torture/execute/20030316-1.c.diff?cvsroot=gcc&r1=NONE&r2=1.1
 
Comment 3 Richard Henderson 2003-03-16 19:46:18 UTC
From: rth@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: target/9164
Date: 16 Mar 2003 19:46:18 -0000

 CVSROOT:	/cvs/gcc
 Module name:	gcc
 Branch: 	gcc-3_3-branch
 Changes by:	rth@gcc.gnu.org	2003-03-16 19:46:18
 
 Modified files:
 	gcc            : ChangeLog tree.c 
 	gcc/testsuite  : ChangeLog 
 Added files:
 	gcc/testsuite/gcc.c-torture/execute: 20030316-1.c 
 
 Log message:
 	PR target/9164
 	* tree.c (get_narrower): For extensions with unchanged bit number,
 	return the unsignedness of the outer mode.
 	
 	* gcc.c-torture/execute/20030316-1.c: New test case.
 
 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.308&r2=1.16114.2.309
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.282&r2=1.282.2.1
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.2261.2.101&r2=1.2261.2.102
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.c-torture/execute/20030316-1.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=NONE&r2=1.1.2.1
 

Comment 4 Richard Henderson 2003-03-16 19:47:36 UTC
From: rth@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: target/9164
Date: 16 Mar 2003 19:47:36 -0000

 CVSROOT:	/cvs/gcc
 Module name:	gcc
 Branch: 	gcc-3_2-branch
 Changes by:	rth@gcc.gnu.org	2003-03-16 19:47:36
 
 Modified files:
 	gcc            : ChangeLog tree.c 
 	gcc/testsuite  : ChangeLog 
 Added files:
 	gcc/testsuite/gcc.c-torture/execute: 20030316-1.c 
 
 Log message:
 	PR target/9164
 	* tree.c (get_narrower): For extensions with unchanged bit number,
 	return the unsignedness of the outer mode.
 	
 	* gcc.c-torture/execute/20030316-1.c: New test case.
 
 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.261&r2=1.13152.2.657.2.262
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree.c.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.241.2.1.4.3&r2=1.241.2.1.4.4
 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.110&r2=1.1672.2.166.2.111
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.c-torture/execute/20030316-1.c.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=NONE&r2=1.1.4.1
Comment 5 Richard Henderson 2003-03-16 19:50:40 UTC
State-Changed-From-To: open->closed
State-Changed-Why: http://gcc.gnu.org/ml/gcc-patches/2003-03/msg01498.html