Subject: Re: com rumblings...
To: Garrett D'Amore <garrett_damore@tadpole.com>
From: Bill Studenmund <wrstuden@netbsd.org>
List: tech-kern
Date: 06/19/2006 11:20:20
--ZoaI/ZTpAVc4A5k6
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Thu, Jun 15, 2006 at 02:38:24PM -0700, Garrett D'Amore wrote:
>=20
> I'm not sure how good gcc's optimizer is at detecting that:
>=20
>     struct {
>        bus_space_handle_t h;
>        bus_space_tag_t   t;
>     } s;
>=20
>     bus_space_write_1(s->t, s->h, OFFSET1, VAL1);
>     /* possibly insert code that doesn't modify s */
>     bus_space_write_1(s->t, s->h, OFFSET2, VAL2);
>=20
> both values of s->t and s->h are really the same and could be cached in
> registers without having to dereference thru s for each
> bus_space_write_1 call.

It probably can't assume that if there's a function call in there
somewhere. Assign them to local variables & be explicit that they can be
cached. :-)

The problem is that the compiler can't (in general) tell if they get=20
changed across a subroutine call. The call can, in principle, block and=20
then things in the structs can get changed.

Obviously if we're using macros, there's no problem. :-)

Take care,

Bill

--ZoaI/ZTpAVc4A5k6
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (NetBSD)

iD8DBQFElurkWz+3JHUci9cRAuOEAJ0RXGTNkxXdJ/PxHdebiOoQ/hvmtgCfW5fF
B1CDULqiQadn5YD7IXe1r/Y=
=JAYu
-----END PGP SIGNATURE-----

--ZoaI/ZTpAVc4A5k6--