public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* asm needs too many reloads
@ 2001-08-16 13:57 jonathan page
  2001-08-16 18:22 ` Alexandre Oliva
  0 siblings, 1 reply; 3+ messages in thread
From: jonathan page @ 2001-08-16 13:57 UTC (permalink / raw)
  To: gcc-help

I got the following error when compiling a large C file with -O3 
optimization: (gcc version 2.95.2 19991024 (release))

emulation.c: In function `execute':
isa.file:8374: `asm' needs too many reloads

The error was not reported  when I commented out this particular inline asm 
in my code.

/* op1, op2, fl, __temp are global variable set elsewhere in the
  program */
\x03
#define FADD_EMU                                           \
{                                                          \
						   	   \
   __asm__ __volatile__(" pushl %%eax\n                    \
  			 fldt %3\n                         \
  			 fldt %2\n                         \
			 faddp %%st(0), %%st(1)\n          \
			 fstpt %0\n                        \
			 fstsw\n		           \
			 movw %%ax, %1\n                   \
			 popl %%eax"                       \
			 :"=g" (__temp), "=g" (fl)         \
			 :"g" (op1), "g" (op2)             \
			 : "st(0)", "st(1)", "ax", "memory"\
			 );                                \
}


Another problem is that I'm unable to reproduce the bug for a program with 
just the above piece of code. (See src code below).

What does this error exactly mean? And what should I do to fix this error?

Thanks in Advance,
jon


---Src code illustrating the use of the above macro---
/* This code snippet works fine...but the problem shows up when
* this macro is included from a large c file with many such macros
*/

#include <stdio.h>
unsigned short fl;
long double  __temp, op1, op2;

#define FADD_EMU                                           \
{                                                          \
						   	   \
   __asm__ __volatile__(" pushl %%eax\n                    \
  			 fldt %3\n                         \
  			 fldt %2\n                         \
			 faddp %%st(0), %%st(1)\n          \
			 fstpt %0\n                        \
			 fstsw\n		           \
			 movw %%ax, %1\n                   \
			 popl %%eax"                       \
			 :"=g" (__temp), "=g" (fl)         \
			 :"g" (op1), "g" (op2)             \
			 : "st(0)", "st(1)", "ax", "memory"\
			 );                                \
}

int main()
{
  op1 = 5.6;
  op2 = 6.4;
  FADD_EMU
  printf("Sum:%llf\n",__temp);
  printf("Status:%d\n"fl);
}

---End of src code---

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp

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

* Re: asm needs too many reloads
  2001-08-16 13:57 asm needs too many reloads jonathan page
@ 2001-08-16 18:22 ` Alexandre Oliva
  0 siblings, 0 replies; 3+ messages in thread
From: Alexandre Oliva @ 2001-08-16 18:22 UTC (permalink / raw)
  To: jonathan page; +Cc: gcc-help

On Aug 16, 2001, "jonathan page" <pagejonathan@hotmail.com> wrote:

> /* This code snippet works fine...but the problem shows up when
> * this macro is included from a large c file with many such macros
> */

Then, we need the large C file ot be able to duplicate the problem.
Or a reduced version thereof that still triggers it.

Consider using local variables to hold copies of op1 and op2, and
other local variables for __temp and fl, explicitly assigned to the
global variables after the asm statement.  I believe this would help
reload do its job.

-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                  aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist    *Please* write to mailing lists, not to me

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

* Re: asm needs too many reloads
@ 2001-08-16 21:37 jonathan page
  0 siblings, 0 replies; 3+ messages in thread
From: jonathan page @ 2001-08-16 21:37 UTC (permalink / raw)
  To: gcc-help

>Consider using local variables to hold copies of op1 and op2, and
>other local variables for __temp and fl, explicitly assigned to the
>global variables after the asm statement.  I believe this would help
>reload do its job.

Thanks for the help. I can compile my code with -O3 now.

Can you tell me (or point me to documents that describe) what exactly
reload accomplishes?

--
jon

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp

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

end of thread, other threads:[~2001-08-16 21:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-08-16 13:57 asm needs too many reloads jonathan page
2001-08-16 18:22 ` Alexandre Oliva
2001-08-16 21:37 jonathan page

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