[llvm-commits] CVS: llvm/lib/Support/APInt.cpp

Reid Spencer reid at x10sys.com
Tue Feb 20 12:42:26 PST 2007



Changes in directory llvm/lib/Support:

APInt.cpp updated: 1.23 -> 1.24
---
Log message:

Clean up variable names in operator*.
Attempt #3 for getting a portable INFINITY value.


---
Diffs of the changes:  (+8 -8)

 APInt.cpp |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)


Index: llvm/lib/Support/APInt.cpp
diff -u llvm/lib/Support/APInt.cpp:1.23 llvm/lib/Support/APInt.cpp:1.24
--- llvm/lib/Support/APInt.cpp:1.23	Tue Feb 20 12:29:12 2007
+++ llvm/lib/Support/APInt.cpp	Tue Feb 20 14:42:10 2007
@@ -17,7 +17,6 @@
 #include "llvm/Support/MathExtras.h"
 #include <cstring>
 #include <cstdlib>
-#include <cmath>
 using namespace llvm;
 
 // A utility function for allocating memory, checking for allocation failures,
@@ -331,7 +330,8 @@
 /// given APInt& RHS and assigns the result to this APInt.
 APInt& APInt::operator*=(const APInt& RHS) {
   assert(BitWidth == RHS.BitWidth && "Bit widths must be the same");
-  if (isSingleWord()) VAL *= RHS.isSingleWord() ? RHS.VAL : RHS.pVal[0];
+  if (isSingleWord()) 
+    VAL *= RHS.VAL;
   else {
     // one-based first non-zero bit position.
     uint32_t first = getActiveBits();
@@ -456,10 +456,10 @@
 /// RHS.
 APInt APInt::operator*(const APInt& RHS) const {
   assert(BitWidth == RHS.BitWidth && "Bit widths must be the same");
-  APInt API(RHS);
-  API *= *this;
-  API.clearUnusedBits();
-  return API;
+  APInt Result(*this);
+  Result *= RHS;
+  Result.clearUnusedBits();
+  return Result;
 }
 
 /// @brief Addition operator. Adds this APInt by the given APInt& RHS.
@@ -838,9 +838,9 @@
   // Return infinity for exponent overflow
   if (exp > 1023) {
     if (!isSigned || !isNeg)
-      return double(INFINITY); // positive infinity
+      return double(1.0E300 * 1.0E300); // positive infinity
     else 
-      return double(-INFINITY); // negative infinity
+      return double(-1.0E300 * 1.0E300); // negative infinity
   }
   exp += 1023; // Increment for 1023 bias
 






More information about the llvm-commits mailing list