[libc-commits] [PATCH] D106604: [libc] Raise denormal exception if the libc defines __FE_DENORM.

Siva Chandra via Phabricator via libc-commits libc-commits at lists.llvm.org
Thu Jul 22 22:42:38 PDT 2021


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc698be47ff8c: [libc] Raise denormal exception if the libc defines __FE_DENORM. (authored by sivachandra).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106604/new/

https://reviews.llvm.org/D106604

Files:
  libc/utils/FPUtil/x86_64/FEnvImpl.h


Index: libc/utils/FPUtil/x86_64/FEnvImpl.h
===================================================================
--- libc/utils/FPUtil/x86_64/FEnvImpl.h
+++ libc/utils/FPUtil/x86_64/FEnvImpl.h
@@ -251,41 +251,29 @@
   // ensure that the writes by the exception handler are maintained
   // when raising the next exception.
 
-  if (statusValue & internal::ExceptionFlags::Invalid) {
+  auto raiseHelper = [](uint16_t  singleExceptFlag) {
     internal::X87StateDescriptor state;
     internal::getX87StateDescriptor(state);
-    state.StatusWord |= internal::ExceptionFlags::Invalid;
-    internal::writeX87StateDescriptor(state);
-    internal::fwait();
-  }
-  if (statusValue & internal::ExceptionFlags::DivByZero) {
-    internal::X87StateDescriptor state;
-    internal::getX87StateDescriptor(state);
-    state.StatusWord |= internal::ExceptionFlags::DivByZero;
-    internal::writeX87StateDescriptor(state);
-    internal::fwait();
-  }
-  if (statusValue & internal::ExceptionFlags::Overflow) {
-    internal::X87StateDescriptor state;
-    internal::getX87StateDescriptor(state);
-    state.StatusWord |= internal::ExceptionFlags::Overflow;
-    internal::writeX87StateDescriptor(state);
-    internal::fwait();
-  }
-  if (statusValue & internal::ExceptionFlags::Underflow) {
-    internal::X87StateDescriptor state;
-    internal::getX87StateDescriptor(state);
-    state.StatusWord |= internal::ExceptionFlags::Underflow;
-    internal::writeX87StateDescriptor(state);
-    internal::fwait();
-  }
-  if (statusValue & internal::ExceptionFlags::Inexact) {
-    internal::X87StateDescriptor state;
-    internal::getX87StateDescriptor(state);
-    state.StatusWord |= internal::ExceptionFlags::Inexact;
+    state.StatusWord |= singleExceptFlag;
     internal::writeX87StateDescriptor(state);
     internal::fwait();
+  };
+
+  if (statusValue & internal::ExceptionFlags::Invalid)
+    raiseHelper(internal::ExceptionFlags::Invalid);
+  if (statusValue & internal::ExceptionFlags::DivByZero)
+    raiseHelper(internal::ExceptionFlags::DivByZero);
+  if (statusValue & internal::ExceptionFlags::Overflow)
+    raiseHelper(internal::ExceptionFlags::Overflow);
+  if (statusValue & internal::ExceptionFlags::Underflow)
+    raiseHelper(internal::ExceptionFlags::Underflow);
+  if (statusValue & internal::ExceptionFlags::Inexact)
+    raiseHelper(internal::ExceptionFlags::Inexact);
+#ifdef __FE_DENORM
+  if (statusValue & internal::ExceptionFlags::Denormal) {
+    raiseHelper(internal::ExceptionFlags::Denormal);
   }
+#endif // __FE_DENORM
 
   // There is no special synchronization scheme available to
   // raise SEE exceptions. So, we will ignore that for now.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D106604.361086.patch
Type: text/x-patch
Size: 2675 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20210723/7a0e0179/attachment.bin>


More information about the libc-commits mailing list