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



Relevant Pages

  • Re: How to: referencing variables using the contents of otehr variables.
    ... comparing and evaluating many thousands of positions each with their ... Assuming the game is chess, you need an array of 64 references to reference squares to pieces -- or 64 bytes, if you want to save some storage at the expense of time -- and perhaps another array of 32 references -- or bytes -- to back-reference pieces to squares. ...
    (comp.lang.java.help)
  • Re: is the < operator transitive?
    ... there are no side-effects (including `volatile' references) ... evaluating a,b,c produces no undefined behavior, and ...
    (comp.lang.c)