Declare some variables unsigned to avoid signed vs unsigned mismatches.
This exploits the relative order of the arguments and/or checks already
made in the functions.
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@158669 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/adddf3.c b/lib/adddf3.c
index 7eb40a1..241726f 100644
--- a/lib/adddf3.c
+++ b/lib/adddf3.c
@@ -85,7 +85,7 @@
// Shift the significand of b by the difference in exponents, with a sticky
// bottom bit to get rounding correct.
- const int align = aExponent - bExponent;
+ const unsigned int align = aExponent - bExponent;
if (align) {
if (align < typeWidth) {
const bool sticky = bSignificand << (typeWidth - align);
diff --git a/lib/addsf3.c b/lib/addsf3.c
index e57270a..a5d24e1 100644
--- a/lib/addsf3.c
+++ b/lib/addsf3.c
@@ -84,7 +84,7 @@
// Shift the significand of b by the difference in exponents, with a sticky
// bottom bit to get rounding correct.
- const int align = aExponent - bExponent;
+ const unsigned int align = aExponent - bExponent;
if (align) {
if (align < typeWidth) {
const bool sticky = bSignificand << (typeWidth - align);
diff --git a/lib/fp_lib.h b/lib/fp_lib.h
index de5f17f..661119a 100644
--- a/lib/fp_lib.h
+++ b/lib/fp_lib.h
@@ -124,7 +124,7 @@
*lo = *lo << count;
}
-static inline void wideRightShiftWithSticky(rep_t *hi, rep_t *lo, int count) {
+static inline void wideRightShiftWithSticky(rep_t *hi, rep_t *lo, unsigned int count) {
if (count < typeWidth) {
const bool sticky = *lo << (typeWidth - count);
*lo = *hi << (typeWidth - count) | *lo >> count | sticky;
diff --git a/lib/muldf3.c b/lib/muldf3.c
index 86d72d8..eb2ff26 100644
--- a/lib/muldf3.c
+++ b/lib/muldf3.c
@@ -96,7 +96,7 @@
// a zero of the appropriate sign. Mathematically there is no need to
// handle this case separately, but we make it a special case to
// simplify the shift logic.
- const int shift = 1 - productExponent;
+ const unsigned int shift = 1U - (unsigned int)productExponent;
if (shift >= typeWidth) return fromRep(productSign);
// Otherwise, shift the significand of the result so that the round
diff --git a/lib/mulsf3.c b/lib/mulsf3.c
index fce2fd4..fc17f4e 100644
--- a/lib/mulsf3.c
+++ b/lib/mulsf3.c
@@ -92,7 +92,7 @@
if (productExponent <= 0) {
// Result is denormal before rounding, the exponent is zero and we
// need to shift the significand.
- wideRightShiftWithSticky(&productHi, &productLo, 1 - productExponent);
+ wideRightShiftWithSticky(&productHi, &productLo, 1U - (unsigned)productExponent);
}
else {