[libc-commits] [PATCH] D95646: [libc][NFC] add static casts to fenv

Michael Jones via Phabricator via libc-commits libc-commits at lists.llvm.org
Thu Jan 28 15:55:22 PST 2021


michaelrj created this revision.
michaelrj added a reviewer: sivachandra.
Herald added subscribers: libc-commits, ecnelises, tschuett.
Herald added a project: libc-project.
michaelrj requested review of this revision.

adding static casts to fenv to deal with loss of precision warnings.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95646

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


Index: libc/utils/FPUtil/x86_64/FEnv.h
===================================================================
--- libc/utils/FPUtil/x86_64/FEnv.h
+++ libc/utils/FPUtil/x86_64/FEnv.h
@@ -290,11 +290,12 @@
     return 1; // To indicate failure
   }
 
-  uint16_t x87Value = bitValue << internal::X87RoundingControlBitPosition;
+  uint16_t x87Value = static_cast<uint16_t>(
+      bitValue << internal::X87RoundingControlBitPosition);
   uint16_t x87Control = internal::getX87ControlWord();
-  x87Control =
+  x87Control = static_cast<uint16_t>(
       (x87Control & ~(0x3 << internal::X87RoundingControlBitPosition)) |
-      x87Value;
+      x87Value);
   internal::writeX87ControlWord(x87Control);
 
   uint32_t mxcsrValue = bitValue << internal::MXCSRRoundingControlBitPosition;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D95646.319980.patch
Type: text/x-patch
Size: 777 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20210128/30cccebe/attachment.bin>


More information about the libc-commits mailing list