Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!border4.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!news.iecc.com!.POSTED!nerds-end From: Kaz Kylheku Newsgroups: comp.compilers Subject: Re: Implementation dependent behaviour (WAS: Re: Programming language and IDE design) Date: Wed, 8 Jan 2014 18:21:15 +0000 (UTC) Organization: Aioe.org NNTP Server Lines: 34 Sender: johnl@iecc.com Approved: comp.compilers@iecc.com Message-ID: <14-01-008@comp.compilers> References: <13-11-025@comp.compilers> <14-01-007@comp.compilers> NNTP-Posting-Host: lnews.iecc.com X-Trace: leila.iecc.com 1389367759 94749 64.57.183.51 (10 Jan 2014 15:29:19 GMT) X-Complaints-To: abuse@iecc.com NNTP-Posting-Date: Fri, 10 Jan 2014 15:29:19 +0000 (UTC) Keywords: C, standards, architecture Posted-Date: 10 Jan 2014 10:29:19 EST 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:1075 On 2014-01-08, Ivan Godard wrote: > On 11/20/2013 2:29 AM, Martin Ward wrote: > > > >> (2) CPU designers may choose to implement that behaviour in hardware >> on the next iteration of the CPU. Now the programs run fast on *all* >> CPUs. >> >> Everybody wins. > > I am such a CPU designer. We faced the "undefined" issue in our Mill > family of general-purpose CPUs (ootbcomp.com). Not only are languages > under-constraining, they are also sometimes over-constraining: signed > integer overflow is undefined in C but required to wrap in Java. It's only undefined on paper. In reality, if you don't make it wrap in C like in Java, unknown numbers of C programs will break, and not all of them doing it by accident. > Our solution was to offer four hardware "overflow-behavior" options for > every operation for which overflow is possible: modulo (wraparound), > excepting, saturating, and double-width result (which cannot overflow). > It is up to the compiler to choose the behavior to match the desired or > mandated semantics. The other behaviors are also available via intrinsics. This kind of thing is quite useful for optimizing certain code. For instance, fixed-point implementations of codecs, in which reproducing bit-exact results over the test vectors requires "saturation" treatment of overflow. Clamping the results in software adds many additional cycles. -- Music DIY Mailing List: http://www.kylheku.com/diy ADA MP-1 Mailing List: http://www.kylheku.com/mp1