This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

c/4134: inline assembly - gcc fails to work around register pressure



>Number:         4134
>Category:       c
>Synopsis:       inline assembly - gcc fails to work around register pressure
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Mon Aug 27 02:16:01 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     jodaman@cegt201.bradley.edu
>Release:        gcc version 3.0.2 20010825 (Debian prerelease)
>Organization:
>Environment:
Linux version 2.2.18 #1 Thu Dec 21 18:49:41 CST 2000
arch: i686
>Description:
The demonstration code attached reveals that gcc may fail
to fold in inline assembly code when most all the registers
are used.  Here is the error message:

test_asm.c: In function `test_asm':
test_asm.c:6: Can't find a register in class `GENERAL_REGS' while reloading `asm'.

Just in guessing, it seems that the compiler fails to copy
a piece of data to the stack when it otherwise runs out of
registers.  The compiler should be able to figure out how
to pass the data to the assembly block without help,
especially since older gcc compilers (like egcs-2.91.66),
handle the code fine.
>How-To-Repeat:
/* compile with "-DBUG" for demonstration */
int
test_asm( int in0, int in1, int in2, int *t )
{
  int out[1];
#ifdef BUG        
  __asm__ (
           ""
           : "=m" (out)
           : "r" (in0)
           , "r" (in1)
           , "r" (in2)
           , "m" (t[0])
           : "%eax", "%ecx", "%edx"
           );
#else
  int workaround_t0 = t[0];
  __asm__ (
           ""
           : "=m" (out)
           : "r" (in0)
           , "r" (in1)
           , "r" (in2)
           , "m" (workaround_t0)
           : "%eax", "%ecx", "%edx"
           );
#endif
  return(*out);
}
>Fix:

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]