[Bug rtl-optimization/6833] gcse generates wrong code with regard to global register variables

bruno at clisp dot org gcc-bugzilla@gcc.gnu.org
Tue Jun 15 16:56:00 GMT 2004


------- Additional Comments From bruno at clisp dot org  2004-06-15 16:56 -------
I think RTH's test case for BR #6722 should be sufficient. Anyway, if you want to commit this 
one too, it needs a small fix, namely to save and restore the value of the global variable. (Yes it 
may make a difference, if the caller of the main() function (in libc) uses %ebx for its own 
purposes.) 
 
======================================= 
register int* p __asm__("%ebx"); 
 
void foo() 
{ 
    --p; 
} 
 
int main() 
{ 
    int a[3] = { 0, 0, 0 }; 
    int *oldp = p; 
    int result; 
 
    p = a+2; 
    do *(p-1)=1; while (!p); 
    foo(); 
 
    result = *(p-1); 
    p = oldp; 
    return result; 
} 
======================================= 

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=6833



More information about the Gcc-bugs mailing list