Re: Optimizing Across && And ||

bill@amber.ssd.hcsc.com (Bill Leonard)
Mon, 3 Apr 1995 15:59:23 GMT

          From comp.compilers

Related articles
[12 earlier articles]
Re: Optimizing Across && And || preston@tera.com (1995-03-08)
Re: Optimizing Across && And || pardo@cs.washington.edu (1995-03-13)
Re: Optimizing Across && And || chase@centerline.com (1995-03-14)
Re: Optimizing Across && And || jqb@netcom.com (1995-03-15)
Re: Optimizing Across && And || cdg@nullstone.com (1995-03-20)
Re: Optimizing Across && And || daniels@cse.ogi.edu (1995-03-21)
Re: Optimizing Across && And || bill@amber.ssd.hcsc.com (1995-04-03)
| List of all articles for this month |
Newsgroups: comp.compilers
From: bill@amber.ssd.hcsc.com (Bill Leonard)
Keywords: C, optimize
Organization: Harris Computer Systems, Ft. Lauderdale FL
References: 95-03-089 95-03-115
Date: Mon, 3 Apr 1995 15:59:23 GMT

cdg@nullstone.com (Christopher Glaeser) writes:
> Jim Balter <uunet!netcom.com!jqb> wrote:
> > It is true that properly written programs shouldn't contain dead code.
>
> Macro expansion, function inline expansion, and many other optimizations
> can also expose dead code in a "properly" (i.e. well) written program.


I agree with Christopher: Properly written programs *may indeed* contain
dead code. And once the optimizer has performed some optimizations on it,
it may contain even more!


For instance, some strength reduction algorithms simply replace array
references in a loop with compiler-generated pointer dereferences, and
replace the loop test with a pointer-based comparison. If the resulting
loop contains no references to the original loop index variable, then the
assignments to that variable are removed by dead-code elimination.


Now you wouldn't want the compiler telling you your loop-index assignments
were unnecessary, would you?


Many optimizers rely on their dead-code elimination phase in this way to
"clean up" after other optimizations. It is easier and more efficient than
having each optimization perform the cleanup separately, but it does
sacrifice the ability to identify truly dead code. But that probably is
not something the average user wants anyway, in view of the points that
Christopher and others raise about assertions, validity checks, macro
expansions, etc.


--
Bill Leonard
Harris Computer Systems Corporation
2101 W. Cypress Creek Road
Fort Lauderdale, FL 33309
Bill.Leonard@mail.hcsc.com
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.