Set Remainder before Quotient in case Quotient and LHS alias. The new
authorJohn McCall <rjmccall@apple.com>
Thu, 24 Dec 2009 08:52:06 +0000 (08:52 +0000)
committerJohn McCall <rjmccall@apple.com>
Thu, 24 Dec 2009 08:52:06 +0000 (08:52 +0000)
order should be immune to such problems.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92124 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Support/APInt.cpp

index 56d47736eabaec6261fa95e1fe07bfa5e8140ca6..9532e1e160bed1329ae36b180259a698ab40ce9f 100644 (file)
@@ -2012,8 +2012,8 @@ void APInt::udivrem(const APInt &LHS, const APInt &RHS,
   }
 
   if (lhsWords < rhsWords || LHS.ult(RHS)) {
-    Quotient = 0;               // X / Y ===> 0, iff X < Y
     Remainder = LHS;            // X % Y ===> X, iff X < Y
+    Quotient = 0;               // X / Y ===> 0, iff X < Y
     return;
   }