[llvm-commits] CVS: llvm/include/llvm/ADT/APInt.h

Reid Spencer reid at x10sys.com
Sat Mar 24 15:37:40 PDT 2007



Changes in directory llvm/include/llvm/ADT:

APInt.h updated: 1.48 -> 1.49
---
Log message:

Undo the last change and make this really implement remainder and not
modulus. The previous change was a result of incorrect documentation in
the LangRef.html.


---
Diffs of the changes:  (+6 -4)

 APInt.h |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)


Index: llvm/include/llvm/ADT/APInt.h
diff -u llvm/include/llvm/ADT/APInt.h:1.48 llvm/include/llvm/ADT/APInt.h:1.49
--- llvm/include/llvm/ADT/APInt.h:1.48	Sat Mar 24 16:56:22 2007
+++ llvm/include/llvm/ADT/APInt.h	Sat Mar 24 17:37:23 2007
@@ -552,9 +552,11 @@
     return this->udiv(RHS);
   }
 
-  /// Perform an Unsigned remainder operation on this APInt with RHS being the
+  /// Perform an unsigned remainder operation on this APInt with RHS being the
   /// divisor. Both this and RHS are treated as unsigned quantities for purposes
-  /// of this operation.
+  /// of this operation. Note that this is a true remainder operation and not
+  /// a modulo operation because the sign follows the sign of the dividend
+  /// which is *this.
   /// @returns a new APInt value containing the remainder result
   /// @brief Unsigned remainder operation.
   APInt urem(const APInt& RHS) const;
@@ -566,9 +568,9 @@
       if (RHS.isNegative())
         return -((-(*this)).urem(-RHS));
       else
-        return (-(*this)).urem(RHS);
+        return -(-(*this)).urem(RHS);
     else if (RHS.isNegative())
-      return -(this->urem(-RHS));
+      return this->urem(-RHS);
     return this->urem(RHS);
   }
 






More information about the llvm-commits mailing list