Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!rpi!think.com!snorkelwacker.mit.edu!mintaka!spdcc!iecc!compilers-sender From: bron@sgi.com (Bron Campbell Nelson) Newsgroups: comp.compilers Subject: Re: Optimizing IEEE Floating-Point Operations Keywords: arithmetic, design, Fortran, C Message-ID: <91-06-011@comp.compilers> Date: 11 Jun 91 19:02:48 GMT References: <91-06-005@comp.compilers> Sender: compilers-sender@iecc.cambridge.ma.us Reply-To: bron@sgi.com (Bron Campbell Nelson) Organization: Compilers Central Lines: 31 Approved: compilers@iecc.cambridge.ma.us Daryl Odnert (daryl@hpclopt.cup.hp.com) writes: > x = 0.0; /* statement A */ > y = y * x; /* statement B */ > Let us assume that x and y are floating-point variables and that the > underlying machine uses the IEEE floating-point representation. Assuming > that we can determine that x does not change between A and B, should the > expression (y * x) in statement B be replaced with 0.0? What if y is a NaN? My own *personal* opinion is that this is a legal transformation if and only if the runtime system traps (and aborts) on generation of NaN's and Inf's. For example, the Fortran standard clearly states that an expression may be replaced by one that is "mathematically equivalent" but without specifing just what kind of "mathematics." If your particular mathematical model includes NaN's and Inf's (e.g. the IEEE model), then this transformation is NOT strictly legal, since the expressions are not always equivalent. On the other hand, if your mathematical model does not have things like NaN's and Inf's (i.e. the program blows up if such numbers are produced) then the transformation IS legal. Probably the "right" thing to do is to add yet another compiler option and support both the "strict IEEE" and "intuitive" models. Just my $0.02 -- Bron Campbell Nelson Silicon Graphics, Inc. 2011 N. Shoreline Blvd. Mtn. View, CA 94039 bron@sgi.com -- Send compilers articles to compilers@iecc.cambridge.ma.us or {ima | spdcc | world}!iecc!compilers. Meta-mail to compilers-request.