[libc-commits] [PATCH] D95646: [libc][NFC] Add a few casts to suppress loss of precision warnings

Michael Jones via Phabricator via libc-commits libc-commits at lists.llvm.org
Thu Jan 28 17:16:21 PST 2021


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd4eea5cf0f5d: [libc][NFC] Add a few casts to suppress loss of precision warnings (authored by michaelrj).

Repository:
  rG LLVM Github Monorepo

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

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,13 @@
     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 & ~(0x3 << internal::X87RoundingControlBitPosition)) |
-      x87Value;
+  x87Control = static_cast<uint16_t>(
+      (x87Control &
+       ~(uint16_t(0x3) << internal::X87RoundingControlBitPosition)) |
+      x87Value);
   internal::writeX87ControlWord(x87Control);
 
   uint32_t mxcsrValue = bitValue << internal::MXCSRRoundingControlBitPosition;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D95646.320009.patch
Type: text/x-patch
Size: 869 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20210129/4f22b3e3/attachment.bin>


More information about the libc-commits mailing list