Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!nbires!vianet!devine From: devine@vianet.UUCP (Bob Devine) Newsgroups: comp.lang.c Subject: Re: re-using registers Message-ID: <209@vianet.UUCP> Date: Mon, 20-Jul-87 15:36:04 EDT Article-I.D.: vianet.209 Posted: Mon Jul 20 15:36:04 1987 Date-Received: Wed, 22-Jul-87 01:59:58 EDT References: <2803@phri.UUCP> Organization: Western Digital, Boulder Tech Ctr Lines: 25 In article <2803@phri.UUCP>, roy@phri.UUCP (Roy Smith) writes: > Are there any C compilers (or other languages, for that matter) > which are smart enough to realize that rs and rp could be put in the same > register? In Fortran you would write this as "EQUIVALENCE (RS, RP)" and > the compiler wouldn't have to be smart at all, but that's cheating. You can increase the likelihood of register re-use if you break up the function into blocks that each declare their own "local" variables. I don't know which compilers will re-use (I believe that PCC descendants will) but this is strictly an implementators choice. Bob Devine [[ Here is the posted code rewritten into blocks. ]] { { register char *rs; for (rs = s; *rs != NULL; rs++); } { register struct foo *rp; for (rp = p; rp->next != NULL; rp = rp->next); } }