Path: utzoo!attcan!uunet!husc6!spdcc!ima!compilers-sender From: tekcrl.tek.com!willc@RELAY.CS.NET (Will Clinger) Newsgroups: comp.compilers Subject: Re: Optimization tradeoffs (time vs. space) Summary: inlining and loop unrolling save time, cost space Message-ID: <1899@ima.ISC.COM> Date: 6 Aug 88 01:57:59 GMT References: <1853@ima.ISC.COM> Sender: compilers-sender@ima.ISC.COM Reply-To: Will Clinger Organization: Tektronix, Inc., Beaverton, OR. Lines: 25 Approved: compilers@ima.UUCP I agree that most optimizations that save time in C-like languages also save space, and vice versa. Someone mentioned the C switch statement as an exception; loop unrolling and procedure integration are others. In some languages the time/space tradeoff is more dramatic. For example, generic arithmetic operations such as addition in Scheme and Common Lisp are too complicated to code in line. The compiler has two practical alternatives. One is to use a subroutine call. The other is to generate code for the most common (fixnum) case in line together with code that traps to a subroutine for all other cases. The simple subroutine call is more compact but is slower. Arithmetic is so ubiquitous that this can make a significant difference. moderately typical # of instructions for generic (+ x 1) static dynamic subroutine call 2 7 inline with trap 6 4 William Clinger Semantic Microsystems, Inc. -- Send compilers articles to ima!compilers or, in a pinch, to Levine@YALE.EDU Plausible paths are { ihnp4 | decvax | cbosgd | harvard | yale | bbn}!ima Please send responses to the originator of the message -- I cannot forward mail accidentally sent back to compilers. Meta-mail to ima!compilers-request