From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8515 invoked by alias); 14 Oct 2002 09:16:02 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 8501 invoked by uid 71); 14 Oct 2002 09:16:02 -0000 Date: Mon, 14 Oct 2002 02:16:00 -0000 Message-ID: <20021014091602.8500.qmail@sources.redhat.com> To: nobody@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, From: Andrew Pinski Subject: Re: c/8221: return value of a function is forgotten Reply-To: Andrew Pinski X-SW-Source: 2002-10/txt/msg00542.txt.bz2 List-Id: The following reply was made to PR c/8221; it has been noted by GNATS. From: Andrew Pinski To: c.kaliszyk@zodiac.mimuw.edu.pl Cc: gcc-gnats@gcc.gnu.org, cek@wp.pl Subject: Re: c/8221: return value of a function is forgotten Date: Mon, 14 Oct 2002 02:12:23 -0700 On Monday, Oct 14, 2002, at 01:44 US/Pacific, c.kaliszyk@zodiac.mimuw.edu.pl wrote: > I call "gcc -O2" on this: > --cut-- > inline int getcputime(void) { > int i; > __asm__( > "rdtsc > movl %%eax, %0" > : :"g" (i) :"ax", "dx"); > return i; > } > > int main(void) { > int x =3D getcputime(); > int y =3D getcputime(); > printf ("Time measure resolution: %i\n", y - x); > return 0; > } I think you constraints are wrong, this works for me: inline int getcputime(void) { int i; __asm__ volatile( "rdtsc\n\ movl %%eax, %0" : "=g" (i) : :"eax", "edx"); return i; } int main(void) { int x = getcputime(); int y = getcputime(); printf ("Time measure resolution: %i\n", y - x); return 0; } read http://gcc.gnu.org/onlinedocs/gcc-3.2/gcc/Extended-Asm.html for information, this helped me get the correct result. Thanks, Andrew Pinski PS I think this bug is user error so can someone close it.