This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug rtl-optimization/6833] gcse generates wrong code with regard to global register variables
- From: "bruno at clisp dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 15 Jun 2004 16:56:15 -0000
- Subject: [Bug rtl-optimization/6833] gcse generates wrong code with regard to global register variables
- References: <20020527043600.6833.bruno@clisp.org>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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