www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/04/14/13:56:03

From: Hans-Bernhard Broeker <broeker AT physik DOT rwth-aachen DOT de>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: THE -O2 PROBLEM
Date: 14 Apr 2000 17:38:56 GMT
Organization: Aachen University of Technology (RWTH)
Lines: 51
Message-ID: <8d7l3g$j3i$1@nets3.rz.RWTH-Aachen.DE>
References: <38F20E7A DOT 3330E9A4 AT mtu-net DOT ru> <38F6C64E DOT C7753C6C AT mtu-net DOT ru>
NNTP-Posting-Host: acp3bf.physik.rwth-aachen.de
X-Trace: nets3.rz.RWTH-Aachen.DE 955733936 19570 137.226.32.75 (14 Apr 2000 17:38:56 GMT)
X-Complaints-To: abuse AT rwth-aachen DOT de
NNTP-Posting-Date: 14 Apr 2000 17:38:56 GMT
Originator: broeker@
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Alexei A. Frounze <alex DOT fru AT mtu-net DOT ru> wrote:

> __asm__ __volatile__ ("
>   fmull (%0)"
>   :
>   : "g" (&variable)
> );
[...]

> But with use of the ``"g" ()'' thing I can't know what will the 
> optimizer do. So, I can't know where I should put those parentheses and 
> where I should not. 

Exactly. The problem is that with the AT&T assembly syntax used by gas
and gcc, it may well be impossible to use the "g" constraint for any
input/output operand. Please do keep in mind that gcc is a
multiplatform compiler, and that you're rather deep inside its guts,
here, so some things that were put into it for other platforms may not
make sense at all, on an Intel one.

> Of course I can use the ``"r" ()'' instead, but this
> means I work instead of the optimizer, but do I have to do *its* job?

No. You just write your code, in whatever way you like. Then you let
GCC do its job, by telling it how you did yours, as correctly as
possible. I.e. if you decided to use a register for that operand,
write
	
	fmull (%0)

and tell GCC to use a register, by the "r" constraint. If, OTOH, you
decide you want to address memory directly, you can write

	fmull %0

and tell GCC to use direct memory reference ("m" that is, I think).

GCC doesn't read the assembly you wrote, as I already pointed out, so
it cannot modify it according to its choice, in the way you think it
should.

> I think no. It must figure out what to do itself and it must not generate
> faulty source code. *Optimizing* doesn't mean *adding bugs*.

It doesn't add a bug, here. The bug's still in your code, as your
assembly operation is not as flexible as the your use of the "g"
constraint claims it is.

-- 
Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de)
Even if all the snow were burnt, ashes would remain.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019