From mboxrd@z Thu Jan 1 00:00:00 1970 From: jodaman@cegt201.bradley.edu To: gcc-gnats@gcc.gnu.org Subject: c/4134: inline assembly - gcc fails to work around register pressure Date: Mon, 27 Aug 2001 02:16:00 -0000 Message-id: <20010827090852.16864.qmail@sourceware.cygnus.com> X-SW-Source: 2001-08/msg00672.html List-Id: >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: