Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Лаб2012 / 25366517.pdf
Скачиваний:
65
Добавлен:
02.02.2015
Размер:
3.33 Mб
Скачать

GUIDELINES FOR WRITING SIMD FLOATING-POINT EXCEPTION

A diagram of the control flow in handling an unmasked floating-point exception is presented below.

User Application

Low-Level Floating-Point Exception Handler

User Level Floating-Point Exception Filter

User Floating-Point Exception Handler

Figure E-1. Control Flow for Handling Unmasked Floating-Point Exceptions

From the user-level floating-point filter, Example E-7 in Section E.4.3, “Example SIMD Float- ing-Point Emulation Implementation” will present only the floating-point emulation part. In order to understand the actions involved, the expected response to exceptions has to be known for all SSE/SSE2/SSE3 numeric instructions in two situations: with exceptions enabled (unmasked result), and with exceptions disabled (masked result). The latter can be found in Section 6.4, “Interrupts and Exceptions”. The response to NaN operands that do not raise an exception is specified in Section 4.8.3.4, “NaNs”. Operations on NaNs are explained in the same source. This response is also discussed in more detail in the next subsection, along with the unmasked and masked responses to floating-point exceptions.

E.4.2 SSE/SSE2/SSE3 Response To Floating-Point Exceptions

This subsection specifies the unmasked response expected from the SSE/SSE2/SSE3 instructions that raise floating-point exceptions. The masked response is given in parallel, as it is necessary in the emulation process of the instructions that raise unmasked floating-point exceptions. The response to NaN operands is also included in more detail than in Section 4.8.3.4, “NaNs”. For floating-point exception priority, refer to ”Priority Among Simultaneous Exceptions and Interrupts” in Chapter 5, Interrupt and Exception Handling, of IA-32 Intel Architecture Software Developer’s Manual, Volume 3.

E-6 Vol. 1

GUIDELINES FOR WRITING SIMD FLOATING-POINT EXCEPTION

E.4.2.1 Numeric Exceptions

There are six classes of numeric (floating-point) exception conditions that can occur: Invalid operation (#I), Divide-by-Zero (#Z), Denormal Operand (#D), Numeric Overflow (#O), Numeric Underflow (#U), and Inexact Result (precision) (#P). #I, #Z, #D are pre-computation exceptions (floating-point faults), detected before the arithmetic operation. #O, #U, #P are post-computa- tion exceptions (floating-point traps).

Users can control how the SSE/SSE2/SSE3 floating-point exceptions are handled by setting the mask/unmask bits in MXCSR. Masked exceptions are handled by the processor, or by software if they are combined with unmasked exceptions occurring in the same instruction. Unmasked exceptions are usually handled by the low-level exception handler, in conjunction with userlevel software.

E.4.2.2 Results of Operations with NaN Operands or a NaN Result for SSE/SSE2/SSE3 Numeric Instructions

The tables below (E-1 through E-10) specify the response of SSE/SSE2/SSE3 instructions to NaN inputs, or to other inputs that lead to NaN results.

These results will be referenced by subsequent tables (e.g., E-10). Most operations do not raise an invalid exception for quiet NaN operands, but even so, they will have higher precedence over raising floating-point exceptions other than invalid operation.

Note that the single precision QNaN Indefinite value is 0xffc00000, the double precision QNaN Indefinite value is 0xfff8000000000000, and the Integer Indefinite value is 0x80000000 (not a floating-point number, but it can be the result of a conversion instruction from floating-point to integer).

For an unmasked exception, no result will be provided by the hardware to the user handler. If a user registered floating-point exception handler is invoked, it may provide a result for the excepting instruction, that will be used if execution of the application code is continued after returning from the interruption.

In Tables E-1 through Table E-12, the specified operands cause an invalid exception, unless the unmasked result is marked with “not an exception”. In this latter case, the unmasked and masked results are the same.

Vol. 1 E-7

GUIDELINES FOR WRITING SIMD FLOATING-POINT EXCEPTION

Table E-1. ADDPS, ADDSS, SUBPS, SUBSS, MULPS, MULSS, DIVPS, DIVSS, ADDPD, ADDSD, SUBPD, SUBSD, MULPD, MULSD, DIVPD, DIVSD, ADDSUBPS, ADDSUBPD, HADDPS, HADDPD, HSUBPS, HSUBPD

Source Operands

Masked Result

Unmasked Result

 

 

 

SNaN1 op1 SNaN2

SNaN1 | 00400000H or

None

 

SNaN1 | 0008000000000000H2

 

SNaN1 op QNaN2

SNaN1 | 00400000H or

None

 

SNaN1 | 0008000000000000H2

 

QNaN1 op SNaN2

QNaN1

None

 

 

 

QNaN1 op QNaN2

QNaN1

QNaN1 (not an exception)

 

 

 

SNaN op real value

SNaN | 00400000H or

None

 

SNaN1 | 0008000000000000H2

 

Real value op SNaN

SNaN | 00400000H or

None

 

SNaN1 | 0008000000000000H2

 

QNaN op real value

QNaN

QNaN (not an exception)

 

 

 

Real value op QNaN

QNaN

QNaN (not an exception)

 

 

 

Neither source operand is SNaN,

Single precision or double

None

but #I is signaled (e.g. for Inf - Inf,

precision QNaN Indefinite

 

Inf 0, Inf / Inf, 0/0)

 

 

 

 

 

NOTES:

 

 

1.For Tables E-1 to E-12: op denotes the operation to be performed.

2.SNaN | 0x00400000 is a quiet NaN in single precision format (if SNaN is in single precision) and SNaN | 0008000000000000H is a quiet NaN in double precision format (if SNaN is in double precision), obtained from the signaling NaN given as input.

3.Operations involving only quiet NaNs do not raise floating-point exceptions.

Table E-2. CMPPS.EQ, CMPSS.EQ, CMPPS.ORD, CMPSS.ORD,

CMPPD.EQ, CMPSD.EQ, CMPPD.ORD, CMPSD.ORD

Source Operands

Masked Result

Unmasked Result

 

 

 

NaN op Opd2 (any Opd2)

00000000H or

00000000H or

 

0000000000000000H1

0000000000000000H1 (not an

 

 

exception)

 

 

 

Opd1 op NaN (any Opd1)

00000000H or

00000000H or

 

0000000000000000H1

0000000000000000H1 (not an

 

 

exception)

 

 

 

NOTE:

1. 32-bit results are for single, and 64-bit results for double precision operations.

E-8 Vol. 1

GUIDELINES FOR WRITING SIMD FLOATING-POINT EXCEPTION

Table E-3. CMPPS.NEQ, CMPSS.NEQ, CMPPS.UNORD, CMPSS.UNORD, CMPPD.NEQ,

CMPSD.NEQ, CMPPD.UNORD, CMPSD.UNORD

Source Operands

Masked Result

Unmasked Result

 

 

 

NaN op Opd2 (any Opd2)

FFFFFFFFH or

FFFFFFFFH or

 

FFFFFFFFFFFFFFFFH1

FFFFFFFFFFFFFFFFH1 (not an

 

 

exception)

Opd1 op NaN (any Opd1)

FFFFFFFFH or

FFFFFFFFH or

 

FFFFFFFFFFFFFFFFH1

FFFFFFFFFFFFFFFFH1 (not an

 

 

exception)

NOTE:

1. 32-bit results are for single, and 64-bit results for double precision operations.

Table E-4. CMPPS.LT, CMPSS.LT, CMPPS.LE, CMPSS.LE, CMPPD.LT, CMPSD.LT,

CMPPD.LE, CMPSD.LE

Source Operands

Masked Result

Unmasked Result

 

 

 

NaN op Opd2 (any Opd2)

00000000H or

None

 

0000000000000000H1

 

Opd1 op NaN (any Opd1)

00000000H or

None

 

0000000000000000H1

 

NOTE:

1. 32-bit results are for single, and 64-bit results for double precision operations.

Table E-5. CMPPS.NLT, CMPSS.NLT, CMPPS.NLE, CMPSS.NLE, CMPPD.NLT,

CMPSD.NLT, CMPPD.NLE, CMPSD.NLE

Source Operands

Masked Result

Unmasked Result

 

 

 

NaN op Opd2 (any Opd2)

FFFFFFFFH or

None

 

FFFFFFFFFFFFFFFFH1

 

Opd1 op NaN (any Opd1)

FFFFFFFFH or

None

 

FFFFFFFFFFFFFFFFH1

 

NOTE:

1. 32-bit results are for single, and 64-bit results for double precision operations.

Vol. 1 E-9

GUIDELINES FOR WRITING SIMD FLOATING-POINT EXCEPTION

Table E-6. COMISS, COMISD

Source Operands

Masked Result

Unmasked Result

 

 

 

SNaN op Opd2 (any Opd2)

OF, SF, AF = 000

None

 

ZF, PF, CF = 111

 

Opd1 op SNaN (any Opd1)

OF, SF, AF = 000

None

 

ZF, PF, CF = 111

 

QNaN op Opd2 (any Opd2)

OF, SF, AF = 000

None

 

ZF, PF, CF = 111

 

Opd1 op QNaN (any Opd1)

OF, SF, AF = 000

None

 

ZF, PF, CF = 111

 

Table E-7. UCOMISS, UCOMISD

Source Operands

Masked Result

Unmasked Result

 

 

 

SNaN op Opd2 (any Opd2)

OF, SF, AF = 000

None

 

ZF, PF, CF = 111

 

 

 

 

Opd1 op SNaN (any Opd1)

OF, SF, AF = 000

None

 

ZF, PF, CF = 111

 

 

 

 

QNaN op Opd2

OF, SF, AF = 000

OF, SF, AF = 000

(any Opd2 SNaN)

ZF, PF, CF = 111

ZF, PF, CF = 111 (not an

 

 

exception)

Opd1 op QNaN

OF, SF, AF = 000

OF, SF, AF = 000

(any Opd1 SNaN)

ZF, PF, CF = 111

ZF, PF, CF = 111 (not an

 

 

exception)

Table E-8. CVTPS2PI, CVTSS2SI, CVTTPS2PI, CVTTSS2SI, CVTPD2PI, CVTSD2SI, CVTTPD2PI, CVTTSD2SI, CVTPS2DQ, CVTTPS2DQ, CVTPD2DQ, CVTTPD2DQ

Source Operand

Masked Result

Unmasked Result

 

 

 

SNaN

80000000H or

None

 

80000000000000001 (Integer

 

 

Indefinite)

 

 

 

 

QNaN

80000000H or

None

 

80000000000000001 (Integer

 

 

Indefinite)

 

 

 

 

NOTE:

1. 32-bit results are for single, and 64-bit results for double precision operations.

Table E-9. MAXPS, MAXSS, MINPS, MINSS, MAXPD, MAXSD, MINPD, MINSD

Source Operands

Masked Result

Unmasked Result

 

 

 

Opd1 op NaN2 (any Opd1)

NaN2

None

 

 

 

NaN1 op Opd2 (any Opd2)

Opd2

None

 

 

 

NOTE:

 

 

1. SNaN and QNaN operands raise an Invalid Operation fault.

E-10 Vol. 1

GUIDELINES FOR WRITING SIMD FLOATING-POINT EXCEPTION

Table E-10. SQRTPS, SQRTSS, SQRTPD, SQRTSD

Source Operand

Masked Result

Unmasked Result

 

 

 

QNaN

QNaN

QNaN (not an exception)

 

 

 

SNaN

SNaN | 00400000H or

None

 

SNaN | 0008000000000000H1

 

Source operand is not SNaN;

Single precision or

None

but #I is signaled (e.g. for

double precision QNaN Indefinite

 

sqrt (-1.0))

 

 

 

 

 

NOTE:

1.SNaN | 00400000H is a quiet NaN in single precision format (if SNaN is in single precision) and SNaN | 0008000000000000H is a quiet NaN in double precision format (if SNaN is in double precision), obtained from the signaling NaN given as input.

Table E-11. CVTPS2PD, CVTSS2SD

Source Operands

Masked Result

Unmasked Result

 

 

 

QNaN

QNaN11

QNaN11 (not an exception)

SNaN

QNaN12

None

NOTES:

1.The double precision output QNaN1 is created from the single precision input QNaN as follows: the sign bit is preserved, the 8-bit exponent FFH is replaced by the 11-bit exponent 7FFH, and the 24-bit significand is extended to a 53-bit significand by appending 29 bits equal to 0.

2.The double precision output QNaN1 is created from the single precision input SNaN as follows: the sign bit is preserved, the 8-bit exponent FFH is replaced by the 11-bit exponent 7FFH, and the 24-bit significand is extended to a 53-bit significand by pending 29 bits equal to 0. The second most significant bit of the significand is changed from 0 to 1 to convert the signaling NaN into a quiet NaN.

Table E-12. CVTPD2PS, CVTSD2SS

Source Operands

Masked Result

Unmasked Result

 

 

 

QNaN

QNaN11

QNaN11 (not an exception)

SNaN

QNaN12

None

NOTES:

1.The single precision output QNaN1 is created from the double precision input QNaN as follows: the sign bit is preserved, the 11-bit exponent 7FFH is replaced by the 8-bit exponent FFH, and the 53-bit significand is truncated to a 24-bit significand by removing its 29 least significant bits.

2.The single precision output QNaN1 is created from the double precision input SNaN as follows: the sign bit is preserved, the 11-bit exponent 7FFH is replaced by the 8-bit exponent FFH, and the 53-bit significand is truncated to a 24-bit significand by removing its 29 least significant bits. The second most significant bit of the significand is changed from 0 to 1 to convert the signaling NaN into a quiet NaN.

Vol. 1 E-11

Соседние файлы в папке Лаб2012