Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!news.iecc.com!.POSTED!nerds-end From: christian.bau@cbau.wanadoo.co.uk Newsgroups: comp.compilers Subject: Re: Compiler optimization and floating point operations Date: Mon, 28 Oct 2013 15:54:46 -0700 (PDT) Organization: Compilers Central Lines: 18 Sender: johnl@iecc.com Approved: comp.compilers@iecc.com Message-ID: <13-10-038@comp.compilers> References: <13-10-026@comp.compilers> <13-10-029@comp.compilers> <13-10-030 @comp.compilers> <13-10-032@comp.compilers> NNTP-Posting-Host: news.iecc.com Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: leila.iecc.com 1383014812 23217 64.57.183.58 (29 Oct 2013 02:46:52 GMT) X-Complaints-To: abuse@iecc.com NNTP-Posting-Date: Tue, 29 Oct 2013 02:46:52 +0000 (UTC) Keywords: optimize Posted-Date: 28 Oct 2013 22:46:52 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:1021 On Thursday, October 24, 2013 5:38:13 PM UTC+1, Steven G. Kargl wrote: > #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? It can eliminate the test because it will always be true (on IEEE implementations where 0.0 / 0.0 is NaN). It cannot eliminate the if-statement because printf () should be called.