From: David Miller <[EMAIL PROTECTED]> Date: Tue, 16 Oct 2007 03:12:23 -0700 (PDT)
> I have a bug I'm trying to investigate where, starting in gcc-4.2.x, > the loop invariant pass considers a computation involving a global > register variable as invariant across a call. The basic structure > of the code is: Here is the most simplified test case I could come up with, compile it with "-m64 -Os" on sparc. expression(regval) is moved to before the loop by loop-invariant register unsigned long regval asm("g5"); extern void cond_resched(void); unsigned int var; void *expression(unsigned long regval) { void *ret; __asm__("" : "=r" (ret) : "0" (&var)); return ret + regval; } void func(void **pp) { int i; for (i = 0; i < 56; i++) { cond_resched(); *pp = expression(regval); } }