#143 non-volatile local variables (hc08)

open
nobody
None
5
2006-05-27
2006-05-27
Zinx Verituse
No

As far as the peephole optimizer is concerned,
allocated local variables are volatile. This makes
some optimizations impossible.

struct {
struct {
unsigned char lo, hi;
} wLength;
} __data __at 0x40 setup_buf;

static unsigned short dummy;

unsigned char foo(void) {
unsigned short maxlen;

maxlen = ((unsigned short)setup_buf.wLength.hi << 8)
| setup_buf.wLength.lo;

if (maxlen > dummy) return 1;
return 0;
}

Produces some pretty unoptimized code, which can not be
optimized using the peephole optimizer, because the
optimizations won't work on the "volatile" _foo_slocN_N_N.

Discussion