Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: notesfiles Path: utzoo!watmath!clyde!burl!ulysses!mhuxr!mhuxt!houxm!mtuxo!mtunh!mtung!mtunf!ariel!vax135!petsd!pesnta!hplabs!hp-pcd!hpdcdb!mike From: mike@hpdcdb.UUCP (mike) Newsgroups: net.lang.c Subject: Re: Orphaned Response Message-ID: <504600001@hpdcdb.UUCP> Date: Thu, 27-Jun-85 16:03:00 EDT Article-I.D.: hpdcdb.504600001 Posted: Thu Jun 27 16:03:00 1985 Date-Received: Thu, 4-Jul-85 04:42:24 EDT References: <38@ucbcad.UUCP> Organization: Hewlett-Packard - Fort Collins, CO Lines: 33 Nf-ID: #R:ucbcad:38:hpdcdb:504600001:37777777600:1558 Nf-From: hpdcdb!mike Jun 27 10:03:00 1985 The chief reason pcc compilers cannot make intelligent register variable selection automatically is that they are single-pass compilers. Some kind of usage count is necessary to select candidates for register variables. By the time the compiler can accumulate a usage count, however, a single-pass compiler has already generated code. Automatically derived usage counts are invariably counts of static references. Such counts are useful but for my money I'd prefer dynamic usage counts. Consequently I've yet to see a compiler algorithm for automatic register variable selection that can beat explicit programmer selection. If anyone does have such an algorithm, please share it. Given the gutsy nature of C that allows the programmer great freedom to allocate registers as he sees fit, I would not be surprised at all if an automatic register allocator was greeted with loud cries of anguish from the programmer community. Register variables do alter the behavior of certain programs because the pcc compiler generates code sequences based on cost estimates. Since the use of register variables reduces the cost of certain subtrees it can change the order of evaluation in the generated code. The only situations I've seen where this matters is in the case of ambiguous source code constructs such as a[i] = a[i++]; I don't have a great deal of sympathy for anyone who gets different results depending on whether or not "i" is a register variable. K & R specifically warn about such constructs. Mike McNelly Hewlett-Packard Corp. hplabs!hpfcla!mike