[fpc-devel] no exceptions from arithmetical operations on AArch64
Edmund Grimley Evans
edmund.grimley.evans at gmail.com
Fri May 29 10:22:33 CEST 2015
>> The compiler adds an explicit comparison to ensure that in case of an
>> integer division by zero, a run time error is raised anyway. The same is
>> done on PowerPC, which doesn't trigger an exception for integer division by
>> zero either.
> As jumps in many cases are slow due to queue issues, this might be a severe
> performance hit.
It's an interesting problem. There may be cases in which you don't
need to know about the exception immediately, in which case you could
avoid conditional branches by doing a conditional select in the loop,
say, and only testing after the loop whether a division by zero has
occurred. However, most branch predictors can cope quite well with a
branch that is almost never taken.
In the case of floating-point operations, the AArch64 hardware does
something like that for you: it sets a sticky bit when the exceptional
thing has happened. However, testing whether that bit has been set is
probably more expensive than checking whether the divisor is zero so
you'd want to put off the test until after several operations.
How much freedom do you have in the choice of which exceptions you
detect and when?
Just for a check list, the AArch64 cumulative exception bits are:
IXC : Inexact
UFC : Underflow
OFC : Overflow
DZC : Division by Zero
IOC : Invalid Operation
(I don't have much practical experience of programming with
floating-point operations, though I have at times studied what AArch64
More information about the fpc-devel