public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* optimization/5366: asm code produces an error without -O but is ok with -O
@ 2002-01-12 16:36 erl-dev
  0 siblings, 0 replies; 3+ messages in thread
From: erl-dev @ 2002-01-12 16:36 UTC (permalink / raw)
  To: gcc-gnats


>Number:         5366
>Category:       optimization
>Synopsis:       asm code produces an error without -O but is ok with -O
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Jan 12 16:36:00 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     Eric Lesage
>Release:        3.0.1 20010716 (prerelease) and others (3.0.3, etc. see below).
>Organization:
>Environment:
System: Linux delta 2.4.17 #1 Tue Jan 8 21:02:30 EST 2002 i686 unknown
Architecture: i686

host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: /home/eric/gcc/gcc-cvs-3.0/configure --prefix=/usr/local/gcc-3.0 --enable-shared --with-gnu-as --with-gnu-ld --enable-languages=c++ --enable-long-long
>Description:
	Also tested with gcc 3.0.3, gcc 2.96-85, egcs 1.1.2,
	gcc 2.95.4 20010319 (prerelease) and gcc 3.1 20011112 (experimental)
	on similar environments (Linux 2.4 i686-pc-linux-gnu).
	
	The attached test case compiles ok if gcc is passed -O or -O2.
	It does not compile otherwise. The problem happens to occur in
	the glibc 2.2.4 pthread spinlock code. The attached test case is
	enough to reproduce the problem (and much smaller).
	The problem I'm reporting is the inconsistency: the code is either
	valid or not (I expect it is valid), but that shouldn't be a
	function of the optimization level.
>How-To-Repeat:
	-- begin test case --
	struct _pthread_fastlock
	{
	  long int __status;
	  int __spinlock;
	};
	
	void __pthread_lock(struct _pthread_fastlock * lock)
	{
	   __asm __volatile ("" : "=m" (lock->__status) : "0" (lock->__status));
	}
	-- end test case --
	
	Compiling the test case with gcc -v -c -o test.o gcctest.c gives:
	
	Reading specs from /usr/local/gcc-3.0/lib/gcc-lib/i686-pc-linux-gnu/3.0.1/specs
	Configured with: /home/eric/gcc/gcc-cvs-3.0/configure --prefix=/usr/local/gcc-3.0 --enable-shared --with-gnu-as --with-gnu-ld --enable-languages=c++ --enable-long-long
	Thread model: single
	gcc version 3.0.1 20010716 (prerelease)
	 /usr/local/gcc-3.0/lib/gcc-lib/i686-pc-linux-gnu/3.0.1/cc1 -lang-c -v -D__GNUC__=3 -D__GNUC_MINOR__=0 -D__GNUC_PATCHLEVEL__=1 -D__ELF__ -Dunix -Dlinux -D__ELF__ -D__unix__ -D__linux__ -D__unix -D__linux -Asystem=posix -D__NO_INLINE__ -D__STDC_HOSTED__=1 -Acpu=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__ -D__tune_i686__ -D__tune_pentiumpro__ gcctest.c -quiet -dumpbase gcctest.c -version -o /tmp/ccdpAEFi.s
	GNU CPP version 3.0.1 20010716 (prerelease) (cpplib) (i386 Linux/ELF)
	GNU C version 3.0.1 20010716 (prerelease) (i686-pc-linux-gnu)
	         compiled by GNU C version 3.0.1 20010716 (prerelease).
	
	ignoring duplicate directory "/usr/local/include"
	#include "..." search starts here:
	#include <...> search starts here:
	/usr/local/include
	/usr/local/ssl/include
	/usr/local/include/kerberosIV
	/usr/local/pgsql/include
	/usr/local/schily/include
	/usr/local/gcc-3.0/lib/gcc-lib/i686-pc-linux-gnu/3.0.1/include
	/usr/local/gcc-3.0/i686-pc-linux-gnu/include
	/usr/include
	End of search list.
	gcctest.c: In function `__pthread_lock':
	gcctest.c:9: inconsistent operand constraints in an `asm'


	Compilation with -O succeeds.

>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:


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

* Re: optimization/5366: asm code produces an error without -O but is ok with -O
@ 2002-01-14 18:26 Richard Henderson
  0 siblings, 0 replies; 3+ messages in thread
From: Richard Henderson @ 2002-01-14 18:26 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR optimization/5366; it has been noted by GNATS.

From: Richard Henderson <rth@redhat.com>
To: erl-dev@altus.qc.ca
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: optimization/5366: asm code produces an error without -O but is ok with -O
Date: Mon, 14 Jan 2002 18:18:39 -0800

 On Sat, Jan 12, 2002 at 07:29:09PM -0500, erl-dev@altus.qc.ca wrote:
 > 	   __asm __volatile ("" : "=m" (lock->__status) : "0" (lock->__status));
 
 You needn't bother with the matching constraint, and that is
 in fact what leads to your troubles.
 
 The memory address is fully specified by lock->__status.  Since
 the same value is used on both sides, you know it is the same
 address, and thus using "=m" and "m" is sufficient.
 
 At -O0, the address calculations for the two structure references
 are not subject to common subexpression elimination, so the 
 register allocator cannot easily prove that the two addresses
 are the same, so it aborts.
 
 
 r~


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

* Re: optimization/5366: asm code produces an error without -O but is ok with -O
@ 2002-01-12 17:17 rodrigc
  0 siblings, 0 replies; 3+ messages in thread
From: rodrigc @ 2002-01-12 17:17 UTC (permalink / raw)
  To: erl-dev, gcc-bugs, gcc-prs, nobody

Synopsis: asm code produces an error without -O but is ok with -O

State-Changed-From-To: open->closed
State-Changed-By: rodrigc
State-Changed-When: Sat Jan 12 17:17:00 2002
State-Changed-Why:
    Duplicate of PR 3038.  You MUST compile with optimization.
    See:
    http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=3038&database=gcc

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=5366


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

end of thread, other threads:[~2002-01-15  2:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-01-12 16:36 optimization/5366: asm code produces an error without -O but is ok with -O erl-dev
2002-01-12 17:17 rodrigc
2002-01-14 18:26 Richard Henderson

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).