9.5 x87 Post-Computation Exceptions

The procedure described in this section is formalized by the functions *x87-binary-post-comp*
and *x87-sqrt-post-comp*.
Each of these functions calls *x87-round*, which performs the rounding and detects exceptions.

In the absence of an unmasked exception, the post-computation behavior of the x87 instructions is the same as that of the corresponding SSE intructions with FTZ = 0, except that (a) results are rounded to the precision specified in the FCW and encoded in the double extended precision format, and (b) if a result if rounded away from 0 or replaced by an infinity, then the condition code C1 is set, and otherwise C1 is cleared.

Here we describe the response of an x87 instruction to an unmasked post-computation exceptional condition. We assume that the computation produces a finite non-zero value , which is rounded according to the rounding mode and the precision indicated by the FCW, producing a value . If lies outside the normal range, then the objective is to return a normal encoding of a shifted version of from which can be recovered:

- Unmasked overflow (
and OM = 0):
OE, ES, and B are set.
Let . If is still above the normal range, then the final result is an infinity with the sign of ; PE and C1 are set.

Otherwise, the final result is the normal encoding of . In this case, PE is set only if . If , then C1 is set; otherwise, C1 is cleared.

- Unmasked underflow (
and UM = 0):
UE, ES, and B are set.
Let . If is still below the normal range, then the final result is a zero with the sign of ; PE is set and C1 is cleared.

Otherwise, the final result is the normal encoding of . In this case, PE is set only if . If , then C1 is set; otherwise, C1 is cleared.

- Unmasked precision exception: The only effect of PM is that if PE is set and PM = 0, then ES and B are set.

David Russinoff 2017-08-01