[libc][NFC] Add a few casts to suppress loss of precision warnings
authorMichael Jones <michaelrj@google.com>
Thu, 28 Jan 2021 23:53:27 +0000 (23:53 +0000)
committerMichael Jones <michaelrj@google.com>
Fri, 29 Jan 2021 01:16:03 +0000 (01:16 +0000)
Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D95646

libc/utils/FPUtil/x86_64/FEnv.h

index 9e0e2be..08379fd 100644 (file)
@@ -290,11 +290,13 @@ static inline int setRound(int mode) {
     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;