Subject: gcc-3.3.1 optimization bug on alpha?
To: None <port-alpha@netbsd.org>
From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
List: port-alpha
Date: 09/27/2003 00:02:40
Today I tried a new kernel compiled gcc-3.3.1 on 3000/300,
and I notice some ioasic devices are not detected correctly:

---
 :
ioasic0 at tc0 slot 5 offset 0x0: slow mode
le0 at ioasic0 offset 0x5d00: address 08:00:2b:3d:d8:ff
le0: 32 receive buffers, 8 transmit buffers
z8530    at ioasic0 offset 0x5d00 not configured
z8530    at ioasic0 offset 0x5d00 not configured
mcclock0 at ioasic0 offset 0x5d00: mc146818 or compatible
bba0 at ioasic0 offset 0x5d00
audio0 at bba0: full duplex, mmap
 :
---

All offset values passed to attachments are 0x5d00, which is wrong.

I put some printf()s in sys/dev/tc/ioasic_subr.c:ioasic_attach_devs(),
then it seems idev.iada_offset is modified after idev.iada_addr is
initialized:

---
        for (i = 0; i < ioasic_ndevs; i++) {
		strncpy(idev.iada_modname, ioasic_devs[i].iad_modname,
			TC_ROM_LLEN);
		idev.iada_modname[TC_ROM_LLEN] = '\0';
		idev.iada_offset = ioasic_devs[i].iad_offset;
printf("1:idev.iada_offset=%" PRIx32 "\n", idev.iada_offset);
		idev.iada_addr = sc->sc_base + ioasic_devs[i].iad_offset;
printf("2:idev.iada_offset=%" PRIx32 "\n", idev.iada_offset);
		idev.iada_cookie = ioasic_devs[i].iad_cookie;

                /* Tell the autoconfig machinery we've found the hardware. */
                config_found(&sc->sc_dv, &idev, ioasicprint);
        }
---
---
ioasic0 at tc0 slot 5 offset 0x0: slow mode
1:idev.iada_offset=c0000
2:idev.iada_offset=5d00
le0 at ioasic0 offset 0x5d00: address 08:00:2b:3d:d8:ff
le0: 32 receive buffers, 8 transmit buffers
1:idev.iada_offset=100000
2:idev.iada_offset=5d00
z8530    at ioasic0 offset 0x5d00 not configured
1:idev.iada_offset=180000
2:idev.iada_offset=5d00
z8530    at ioasic0 offset 0x5d00 not configured
1:idev.iada_offset=200000
2:idev.iada_offset=5d00
mcclock0 at ioasic0 offset 0x5d00: mc146818 or compatible
1:idev.iada_offset=240000
2:idev.iada_offset=5d00
bba0 at ioasic0 offset 0x5d00
audio0 at bba0: full duplex, mmap
---

Note compiling sys/dev/tc/ioasic_subr.c with -O fixes this problem:

---
ioasic0 at tc0 slot 5 offset 0x0: slow mode
1:idev.iada_offset=c0000
2:idev.iada_offset=c0000
le0 at ioasic0 offset 0xc0000: address 08:00:2b:3d:d8:ff
le0: 32 receive buffers, 8 transmit buffers
1:idev.iada_offset=100000
2:idev.iada_offset=100000
zsc0 at ioasic0 offset 0x100000
vsms0 at zsc0 channel 0
wsmouse0 at vsms0 mux 0
zstty0 at zsc0 channel 1
1:idev.iada_offset=180000
2:idev.iada_offset=180000
zsc1 at ioasic0 offset 0x180000
lkkbd0 at zsc1 channel 0
wskbd0 at lkkbd0: console keyboard, using wsdisplay0
zsc1: channel 1 not configured
1:idev.iada_offset=200000
2:idev.iada_offset=200000
mcclock0 at ioasic0 offset 0x200000: mc146818 or compatible
1:idev.iada_offset=240000
2:idev.iada_offset=240000
bba0 at ioasic0 offset 0x240000
audio0 at bba0: full duplex, mmap
---

Any thoughts?
---
Izumi Tsutsui
tsutsui@ceres.dti.ne.jp