Processors
Intel® Processors, Tools, and Utilities
14484 Discussions

QUESTION on x87 FPU Inexact result exception

seoyounglu
Beginner
571 Views

When implementing 80-bit FPU in my processor with the manual Intel® 64 and IA-32 Archi-
tectures Software Developer’s Manual
, I found a strange phenomenon:

The manual says about ineaxct-result exception in 8.5.6, that 

"If an inexact result occurs in conjunction with numeric overflow or underflow, the x87 FPU carries out one of the following operations:

- If an inexact result occurs in conjunction with masked overflow or underflow, the OE or UE flag and the PE flag are set and the result is stored as described for the overflow or underflow exceptions (see Section 8.5.4, “Numeric Overflow Exception (#O),” or Section 8.5.5, “Numeric Underflow Exception (#U)”). If the inexact result exception is unmasked, the x87 FPU also invokes a software exception handler.

- If an inexact result occurs in conjunction with unmasked overflow or underflow and the destination operand is a register, the OE or UE flag and the PE flag are set, the result is stored as described for the overflow or underflow exceptions (see Section 8.5.4, “Numeric Overflow Exception (#O),” or Section 8.5.5, “Numeric Underflow Exception (#U)”) and a software exception handler is invoked."

Screenshot from 2023-01-30 19-30-18.png

I think it means whether encountered masked overflow or unmasked overflow, when the operation result (except fp store) is overflowed, I should set both OE and PE flag.

 

But when I tested on my laptop with 12th Gen Intel(R) Core(TM) i7-12700H, Alder lake arch, and Intel Xeon, P6 arch, unmasked all exceptions, it turned out that:

(80-bit)a = 0x7ffe_ffff_ffff_ffff_ffff;
(80-bit)b = 0x7ffe_8000_0000_0000_0000;

(a + b) do catch a SIGFEP exception, control word = 0x340, status word = 0xb888, which means only OE flag is set, though expected OE and PE flags both set (status word = 0xb8a8).

(80-bit)a = 0x7ffe_ffff_ffff_ffff_ffff;
(80-bit)c = 0x7ffe_8000_0000_0000_0001;

This time, (a + c)  catch a SIGFEP exception, control word = 0x340, status word = 0xb8a8, which means OE and PE flags are both set.

 

I also tested many other cases. Some set OE and PE, some just set OE.

 

I am really confused with these results. It is untrackable. It is against the manual! Hope to get some explaination. Thank you!

 

 

 

0 Kudos
1 Reply
Steven_Intel
Moderator
501 Views

Hello seoyounglu,


Thank you for posting on the Intel® communities.


We recommend you going to the Intel Developer Zone (https://www.intel.com/content/www/us/en/developer/overview.html#gs.pcr8sv) for further support.


Please keep in mind that this thread will no longer be monitored by Intel. Thank you for your understanding.  


Best regards,


Steven G.

Intel Customer Support Technician.


0 Kudos
Reply