www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/04/14/11:59:29

From: "Alexei A. Frounze" <alex DOT fru AT mtu-net DOT ru>
Newsgroups: comp.os.msdos.djgpp
Subject: THE -O2 PROBLEM
Date: Fri, 14 Apr 2000 11:18:38 +0400
Organization: MTU-Intel ISP
Lines: 59
Message-ID: <38F6C64E.C7753C6C@mtu-net.ru>
References: <38F20E7A DOT 3330E9A4 AT mtu-net DOT ru>
NNTP-Posting-Host: ppp96-173.dialup.mtu-net.ru
Mime-Version: 1.0
X-Trace: gavrilo.mtu.ru 955728298 46009 212.188.96.173 (14 Apr 2000 16:04:58 GMT)
X-Complaints-To: usenet-abuse AT mtu DOT ru
NNTP-Posting-Date: 14 Apr 2000 16:04:58 GMT
X-Mailer: Mozilla 4.61 [en] (Win95; I)
X-Accept-Language: en,ru
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Please read the following text *entirely* instead of reading a part and then
talking about it. Entirely!!!

If I use something like this in my inline ASM:

__asm__ __volatile__ ("
  fmull (%0)"
  :
  : "g" (&variable)
);

I have some problems...

If optimizer doesn't put address of the variable to a conventional
register (EAX,EBX,ECX,EDX,ESI,EDI) with the following instruction:

LEA register, [ebp-offset] (sorry for Intel syntax), 

the following assembly source code is generated out of my inline ASM:

  fmull   (-140(%ebp))

Here first and last parentheses crash the AS with these error messages:

"Error: Error: Missing ')' assumed"
"Error: Error: Ignoring junk `(%ebp))' after expression")"

If I remove these parentheses manually, "bug" goes away.

Also I can "patch" my source and bug will also go away:

__asm__ __volatile__ ("
  fmull %0"
  :
  : "g" (&variable)
);

BUT!!!

If the optimizer puts the address of the variable to any of conventional 
registers (EAX,EBX,ECX,EDX,ESI,EDI), generated the following code:

  fmull   (%ecx)

which is recognized by AS.

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. 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?
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*.

Thanks for reading it attentively.

Now is time for your comments, thoughts, ideas.

Alexei A. Frounze

- Raw text -


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