comp.lang.ada
 help / color / mirror / Atom feed
From: tinton.ccur.com!cjh@princeton.edu  (Christopher J. Henrich)
Subject: Re: and then
Date: 8 Apr 93 15:34:59 GMT	[thread overview]
Message-ID: <1993Apr8.153459.8896@tinton.ccur.com> (raw)

In article <1993Apr7.162133.3564@nosc.mil> sampson@nosc.mil (Charles H. Sampson
) writes:
>     My style is to use the boolean operators generally, reserving the
>short-circuit forms to document that the second operand should not be eval-
>uated under some circumstances.
>
>     Unfortunately, that style can conflict with efficiency considerations. 
>Ada compiler writers appear to have abdicated their responsibility and make
>no attempt to determine when boolean operations can be optimized as short-
>circuit.  (Somebody contradict me, please.)  
All right....

The C3Ada compiler, which runs on the Series 3200 machines produced
by Concurrent Computer Corporation, does optimize AND into AND THEN;
likewise, OR into OR ELSE.  As you point out, this is legal only if
the operands are free of side effects - basically, calls to user
defined functions.  And there are circumstances where the
transformation, though legal, is not optimal, such as

   FLAG1 := FLAG2 and FLAG3;

The compiler tries to avoid doing the transformation in such cases.

>... [T]here are cases when it is unreasonable to expect such an optimization; 
> when the
>second operand contains a function reference, for example.
>
>     That said, I still use my style when coding and look for bottlenecks
>during testing if performance is poor.  If efficiency requires that I use
>an unnecessary short-circuit form, I document that fact in the code.
>
>                                   Charlie
>

Regards,
Chris Henrich

             reply	other threads:[~1993-04-08 15:34 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1993-04-08 15:34 Christopher J. Henrich [this message]
  -- strict thread matches above, loose matches on Subject: below --
1993-04-12 18:38 and then Charles H. Sampson
1993-04-12 13:29 cis.ohio-state.edu!zaphod.mps.ohio-state.edu!howland.reston.ans.net!noc.n
1993-04-11  3:55 Michael Feldman
1993-04-10 19:52 Alex Blakemore
1993-04-10 15:43 Dik T. Winter
1993-04-10 15:36 Dik T. Winter
1993-04-10  9:39 munnari.oz.au!yoyo.aarnet.edu.au!news.adelaide.edu.au!usenet
1993-04-10  1:03 Charles H. Sampson
1993-04-09 18:08 Dave Bashford
1993-04-09 14:06 Dan Rittersdorf
1993-04-08 22:35 Andrew Dunstan,,2285592,
1993-04-08 22:28 Alex Blakemore
1993-04-08 19:03 Art Duncan
1993-04-08 16:18 Charles H. Sampson
1993-04-08 12:21 enterpoop.mit.edu!usc!cs.utexas.edu!mars.tsd.arlut.utexas.edu!gardner
1993-04-07 22:58 Mark Lundquist
1993-04-07 21:07 Ray Harwood -- Data Basix: (602)721-1988
1993-04-07 16:21 Charles H. Sampson
1993-04-07 12:42 Robert Firth
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox