aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm/ADT/APInt.h
diff options
context:
space:
mode:
authorNuno Lopes <nunoplopes@sapo.pt>2012-05-22 01:09:48 +0000
committerNuno Lopes <nunoplopes@sapo.pt>2012-05-22 01:09:48 +0000
commita7a2a3635f2fbe46d7d9074798e79e853f69d40b (patch)
treea8eff441253ba0dd28644172d2aa310d9b71bd0f /include/llvm/ADT/APInt.h
parent6b07bc604ee891185435c040f0a872774c64af29 (diff)
downloadexternal_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.h5
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);