Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!news-out.readnews.com!news-xxxfer.readnews.com!news.misty.com!news.iecc.com!.POSTED!nerds-end From: glen herrmannsfeldt Newsgroups: comp.compilers Subject: Re: Compiler optimization and floating point operations Date: Thu, 24 Oct 2013 02:56:06 +0000 (UTC) Organization: Aioe.org NNTP Server Lines: 36 Sender: johnl@iecc.com Approved: comp.compilers@iecc.com Message-ID: <13-10-028@comp.compilers> References: <13-10-026@comp.compilers> NNTP-Posting-Host: news.iecc.com X-Trace: leila.iecc.com 1382619369 51459 64.57.183.58 (24 Oct 2013 12:56:09 GMT) X-Complaints-To: abuse@iecc.com NNTP-Posting-Date: Thu, 24 Oct 2013 12:56:09 +0000 (UTC) Keywords: arithmetic, optimize Posted-Date: 24 Oct 2013 08:56:09 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:1011 Abid wrote: (snip) > Does back end compiler optimizations affect the floating point > accuracy? Is there any research work in this area? As far as I know, the biggest cause of problems with optimization is the extended precision of the registers in the Intel x87. The original design of the 8087 was for a virtual stack that would spill on overflow, and (what is the opposite of spill?) on underflow. Not until the hardware was ready did anyone try to write the interrupt routine to handle it, and it turned out not to be possible. The required state information was either not available, could not be restored, or both. Compilers could write temporary intermediates to memory in temporary real format, but that is rare. Next comes the complication of optimization. Common subexpression elimination between statements, or in general keeping values in registers, means that some values will retain extra precision, but you (the programmer) don't know which ones. Even if you assign to a variable and reload, the optimizer might keep it in a register. (Many compilers have an option to force the store, but that can slow things down.) I don't know about the research that might be done. The x87 has an eight element stack. Research won't change that, though the use of SSE avoids the problem (and advantage) of extended precision. The technology for doing optimization is reasonably well understood. Knowing which ones you should do it a different problem. -- glen