Open yuxianch opened 5 years ago
Additional info: We have fesetround function (see in fenv.h) to set rounding modes in both x87 control register and MXCSR. It is probably easier to use it. We have also fegetround but it returns Rounding Mode bits from MXCSR in Linux.
Code to reproduce:
When linking with -limf(Intel's LIBM Math library), this test would got failed when running. Below is the error message.
This test changed rounding mode only on x87 FPU control register (bits 10 and 11) but not on MXCSR register (bits 13 and 14). There are functions in LIBM that could use x87 or simd instructions. In this case, SSE version of sqrt is called and it uses "sqrtsd %xmm0,%xmm0" instruction. This sqrtsd instruction uses the rounding mode that is in the MXCSR. Therefore, the rounding bits in MXCSR should be updated as well.