public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* gcc optimises out test of value in register-only loop
@ 2011-10-13 11:35 MikeW
  2011-10-13 11:38 ` Andrew Haley
  2011-10-14  4:41 ` Ian Lance Taylor
  0 siblings, 2 replies; 12+ messages in thread
From: MikeW @ 2011-10-13 11:35 UTC (permalink / raw)
  To: gcc-help

sh4-linux-gcc (GCC) 4.2.4 [unfortunately the version is tied to the
 kernel build. ]

In some kernel code where RAM is unavailable due to manipulation of the MMU,
I wanted to place some 'got here' stops in the code so I could ^C break in gdb,
reset a register value and allow execution to continue.

Accordingly I tried:
  volatile register int stop_loop __asm("r5")__;
...
  stop_loop = 0x1234;
  (disable MMU)
  while (stop_loop != 0);
...

which seemed to generate code that checks the value of r5 only once:

xxxx08: mov r5,r1
xxxx0a: tst r1,r1
xxxx0c: bf xxxx0c   ;r5 never tested again!!
xxxx0e: (unrelated code)

I also tried
  while ((volatile)stop_loop != 0);
and
  while ((volatile)(stop_loop != 0));

which both gave the original asm code as above.

So, in short, is there any way to persuade gcc to reload r5 - which could
in other non-debug situations be a global register variable updated
in an ISR, for example.

Or perhaps this is 'fixed' in a later gcc ...

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2011-10-17  8:30 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-13 11:35 gcc optimises out test of value in register-only loop MikeW
2011-10-13 11:38 ` Andrew Haley
2011-10-13 11:56   ` MikeW
2011-10-13 11:58     ` Thomas Martitz
2011-10-13 12:01     ` Andrew Haley
2011-10-13 12:14       ` MikeW
2011-10-13 12:18         ` Andrew Haley
2011-10-13 12:05   ` MikeW
2011-10-14  4:41 ` Ian Lance Taylor
2011-10-14  9:07   ` Andrew Haley
2011-10-15  3:20     ` Ian Lance Taylor
2011-10-17  8:30       ` Andrew Haley

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).