🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.misc
Article #1758

Re: Aggressive optimization

#1758
From: Jim Giles
Date: Thu, 18 Oct 1990 21:55
31 lines
2126 bytes
From article <13405:Oct1800:22:5690@kramden.acf.nyu.edu>, by brnstnd@kramden.acf.nyu.edu (Dan Bernstein):
> [...]
> I do not remember ever making a mistake in hand optimization by the most
> fundamental standard technique: adding variable x to keep track of some
> intermediate quantity, and eliminating redundant variables given x. What
> optimizer can do this for any but the most primitive intermediate
> expressions? (Introducing a pointer to traverse an array, and
> eliminating the index that it replaces, is the simplest example.)

_ALL_ production quality compilers I've ever used on mainframes can do
much better than all but the most adept programmer at this optimization.
Further, the adept programmer can usually do no better than the compiler.
Compilers have been able to do this quite well since I started programming
23 years ago.  This is one of the reasons that your claim that pointers
are more efficient that arrays is completely incorrect.

In fact, the only place a production quality compiler (the only kind
worth paying for) would fail to make this optimization is when it is
actually _more_ efficient to recompute the index than to reload the
saved value from memory.  And _this_ decision is a feedback from the
register allocation mechanism - so the user _can't_ do this unless he
wants to take _complete_ responsibility for register allocation.  But,
register allocation is machine dependent - anyway it's another of
those things that compilers are usually better than people at.

In the meantime, there _are_ types of optimization that compilers
_can't_ do yet.  The adept programmer should spend his time on those
rather than wasting it on things the compiler can do more quickly
and reliably.

J. Giles
Technical Details
Message-ID: <66071@lanl.gov>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!yale!cmcl2!lanl!jlg
References: <13405:Oct1800:22:5690@kramden.acf.nyu.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!yale!cmcl2!lanl!jlg
From: jlg@lanl.gov (Jim Giles)
Newsgroups: comp.lang.misc
Subject: Re: Aggressive optimization
Message-ID: <66071@lanl.gov>
Date: 18 Oct 90 21:55:17 GMT
References: <13405:Oct1800:22:5690@kramden.acf.nyu.edu>
Organization: Los Alamos Natl Lab, Los Alamos, N.M.
Lines: 31