On Tue, Jun 4, 2013 at 7:35 AM, Richard A. O'Keefe
<ok@cs.otago.ac.nz> wrote:
On 3/06/2013, at 6:58 PM, Carter Schonwald wrote:
> If the Int type had either of these semantics by default, many many performance sensitive libraries would suddenly have substantially less compelling performance. Every single operation that was branchless before would have a branch *every* operation..... this would be BAD.
Actually, the x86 can be configured to trap integer overflows,
so on that not entirely unpopular platform, there need be NO
extra branches.
Well yes and no. See
http://software.intel.com/en-us/forums/topic/306156Using instructions like cmovo "Conditional MOve on Overflow" we can test without a branch -- so in that sense yes.
No, because the use of the word 'trap' is a bit misleading. If we understand 'trap' as synchronous interrupt, then intel provides the infrastructure to literally trap floating point errors but for integers such a 'trap' only works if the instruction stream contains instructions like INTO or CMOVO etc.
Alternatively, and more portably, there could be separate
Int and UnsafeInt types, and the performance sensitive libraries
could be rewritten to use UnsafeInt.
For just one week, I had the joy of using a C compiler where
signed integer overflow was trapped. It was *wonderful*.