Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newspeer1.nac.net!border4.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!news.iecc.com!.POSTED!nerds-end From: "Steven G. Kargl" Newsgroups: comp.compilers Subject: Re: Compiler optimization and floating point operations Date: Thu, 24 Oct 2013 16:38:13 +0000 (UTC) Organization: A noiseless patient Spider Lines: 32 Sender: johnl@iecc.com Approved: comp.compilers@iecc.com Message-ID: <13-10-032@comp.compilers> References: <13-10-026@comp.compilers> <13-10-029@comp.compilers> <13-10-030 @comp.compilers> NNTP-Posting-Host: news.iecc.com Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Trace: leila.iecc.com 1382647441 75460 64.57.183.58 (24 Oct 2013 20:44:01 GMT) X-Complaints-To: abuse@iecc.com NNTP-Posting-Date: Thu, 24 Oct 2013 20:44:01 +0000 (UTC) Keywords: arithmetic, comment Posted-Date: 24 Oct 2013 16:44:01 EDT X-submission-address: compilers@iecc.com X-moderator-address: compilers-request@iecc.com X-FAQ-and-archives: http://compilers.iecc.com Xref: csiph.com comp.compilers:1015 On Thu, 24 Oct 2013 15:51:59 +0200, Jean-Marc Bourguet wrote: > George Neuner writes: > >> [I think you mean they're not associative. I don't know any situations >> where a+b != b+a, but lots where a+(b+c) != (a+b)+c -John] > > You forgot about NaN ;-) (but I agree associative was probably intended). > > Yours, > -- > Jean-Marc [How are NaNs not commutative? -John] I believe Jean-Marc is referring to something like the following #include int main(void) { float a, b; a = 0.; b = a / a; if (a + b != b + a) printf("fubar\n"); return (0); } Can an optimizing compiler eliminate the if-statement? -- steve [If it does sufficient dataflow and constant substitutions so it can tell that a+b will always be a NaN, I don't see why not. -John]