diff options
author | Nuno Lopes <nunoplopes@sapo.pt> | 2012-05-22 01:09:48 +0000 |
---|---|---|
committer | Nuno Lopes <nunoplopes@sapo.pt> | 2012-05-22 01:09:48 +0000 |
commit | a7a2a3635f2fbe46d7d9074798e79e853f69d40b (patch) | |
tree | a8eff441253ba0dd28644172d2aa310d9b71bd0f /include/llvm/ADT/APInt.h | |
parent | 6b07bc604ee891185435c040f0a872774c64af29 (diff) | |
download | external_llvm-a7a2a3635f2fbe46d7d9074798e79e853f69d40b.zip external_llvm-a7a2a3635f2fbe46d7d9074798e79e853f69d40b.tar.gz external_llvm-a7a2a3635f2fbe46d7d9074798e79e853f69d40b.tar.bz2 |
fix the quotient returned by sdivrem() for the case when LHS is negative and RHS is positive
based on a patch by Preston Briggs, with some modifications
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@157231 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/ADT/APInt.h')
-rw-r--r-- | include/llvm/ADT/APInt.h | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/include/llvm/ADT/APInt.h b/include/llvm/ADT/APInt.h index 4101989..eb7192c 100644 --- a/include/llvm/ADT/APInt.h +++ b/include/llvm/ADT/APInt.h @@ -817,9 +817,10 @@ public: if (LHS.isNegative()) { if (RHS.isNegative()) APInt::udivrem(-LHS, -RHS, Quotient, Remainder); - else + else { APInt::udivrem(-LHS, RHS, Quotient, Remainder); - Quotient = -Quotient; + Quotient = -Quotient; + } Remainder = -Remainder; } else if (RHS.isNegative()) { APInt::udivrem(LHS, -RHS, Quotient, Remainder); |