Re: Function PRESENT and logical combinations

From: Ron Shepard (ron-shepard_at_NOSPAM.comcast.net)
Date: 06/16/04


Date: Tue, 15 Jun 2004 22:58:12 -0500

In article
<kPIzc.72551$Gx4.46495@bgtnsc04-news.ops.worldnet.att.net>,
 "James Giles" <jamesgiles@worldnet.att.net> wrote:

> > The processor doesn't have to "evaluate each operand",
> > so, in an expression like
> > A = 0 * F(x)
> > the processor might not need to evaluate F(x) and then the
> > side-effects become undefined. [...]
>
> But this does not constitute a an alternative way of evaluating
> the function, it provides for means of evaluating the *expression*
> as a whole that no longer even references the function. If no
> such alternative means exists, and the function is evaluated,
> that occurs by execution.

What if the statement is simply

  A = F(x)

but the local variable A is not referenced afterwards? Is the
compiler allowed to optimize away entirely the function reference?
Or what about something like

  A = F(x)
  A = 0

or

  A = F(x)
  if (.true.) A = 1

Can the function execution be optimized away entirely in these cases?

$.02 -Ron Shepard