diff options
author | Reid Spencer <rspencer@reidspencer.com> | 2007-03-24 21:56:22 +0000 |
---|---|---|
committer | Reid Spencer <rspencer@reidspencer.com> | 2007-03-24 21:56:22 +0000 |
commit | 3e51cacd4fcb0b52dbc0c52423dc7fcef52ed39a (patch) | |
tree | f20088f1f415d03e52e3532d9f116c28348f4e6a | |
parent | 71a6ef7f0e10ad3dce5f46dcb1f2d456d32bc9a2 (diff) | |
download | bcm5719-llvm-3e51cacd4fcb0b52dbc0c52423dc7fcef52ed39a.tar.gz bcm5719-llvm-3e51cacd4fcb0b52dbc0c52423dc7fcef52ed39a.zip |
Correct the implementation of srem to be remainder, not modulus. The sign of
the result must follow the sign of the divisor.
llvm-svn: 35302
-rw-r--r-- | llvm/include/llvm/ADT/APInt.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/llvm/include/llvm/ADT/APInt.h b/llvm/include/llvm/ADT/APInt.h index 44b5fd0403f..52509ed000c 100644 --- a/llvm/include/llvm/ADT/APInt.h +++ b/llvm/include/llvm/ADT/APInt.h @@ -564,9 +564,9 @@ public: inline APInt srem(const APInt& RHS) const { if (isNegative()) if (RHS.isNegative()) - return (-(*this)).urem(-RHS); + 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); |