🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.misc
Article #5653

Query re optimising compilers

#5653
From: Dave Berry
Date: Fri, 22 Jul 1988 18:54
39 lines
1637 bytes
Background:

Several languages leave the order of evaluation of the arguments of
operators undefined.  This allows compilers to optimise expressions
containing such operators.

Question:

Does anyone know of any compilers which produce code that decides the order
of evaluation at run-time?   My guess is that most of these optimisations
are made at compile-time.

Would it be sensible to optimise the following code:

a := function ();
b := (complicated expression) * a;

to the equivalent of:

a:= function ();
if (a == 0)
  b := 0;
else
  (complicated expression) * a;


Assuming:
  the result returned by "function" is a very small integer (including 0),
	and isn't known at compile-time
  "complicated_expression" has no side-effects and would take much longer
	to evaluate than a comparison with 0.
  the time taken to compile a program isn't considered.


I'd like to be able to reference such a compiler.  However, I expect that
cases like this occur too infrequently to be worth bothering with.

 Dave Berry.		  "May you have interesting weather"
 db@lfcs.ed.ac.uk	   	   -- Ancient British curse.
Technical Details
Message-ID: <561@etive.ed.ac.uk>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!att!pacbell!lll-tis!helios.ee.lbl.gov!pasteur!agate!ucbvax!decwrl!sun!pitstop!sundc!seismo!uunet!mcvax!ukc!etive!lfcs!db

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!att!pacbell!lll-tis!helios.ee.lbl.gov!pasteur!agate!ucbvax!decwrl!sun!pitstop!sundc!seismo!uunet!mcvax!ukc!etive!lfcs!db
From: db@lfcs.ed.ac.uk (Dave Berry)
Newsgroups: comp.lang.misc
Subject: Query re optimising compilers
Message-ID: <561@etive.ed.ac.uk>
Date: 22 Jul 88 18:54:38 GMT
Sender: news@etive.ed.ac.uk
Reply-To: db@lfcs.ed.ac.uk (Dave Berry)
Organization: Laboratory for the Foundations of Computer Science, Edinburgh U
Lines: 39