summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/APInt.cpp
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2012-07-11 18:31:59 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2012-07-11 18:31:59 +0000
commit3aab6a86a263369fc49a6180f9163d0077435a02 (patch)
tree032ed840b1df0cdc2b54e4f3f87aa5a9213b75bb /llvm/lib/Support/APInt.cpp
parent1fa9fade3855a0c8c1bc067a3f322fdef05191d9 (diff)
downloadbcm5719-llvm-3aab6a86a263369fc49a6180f9163d0077435a02.tar.gz
bcm5719-llvm-3aab6a86a263369fc49a6180f9163d0077435a02.zip
PR13326: Fix a subtle edge case in the udiv -> magic multiply generator.
This caused 6 of 65k possible 8 bit udivs to be wrong. llvm-svn: 160058
Diffstat (limited to 'llvm/lib/Support/APInt.cpp')
-rw-r--r--llvm/lib/Support/APInt.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/llvm/lib/Support/APInt.cpp b/llvm/lib/Support/APInt.cpp
index 6a74883803c..38cfaed9d21 100644
--- a/llvm/lib/Support/APInt.cpp
+++ b/llvm/lib/Support/APInt.cpp
@@ -1446,7 +1446,7 @@ APInt::mu APInt::magicu(unsigned LeadingZeros) const {
APInt signedMin = APInt::getSignedMinValue(d.getBitWidth());
APInt signedMax = APInt::getSignedMaxValue(d.getBitWidth());
- nc = allOnes - (-d).urem(d);
+ nc = allOnes - (allOnes - d).urem(d);
p = d.getBitWidth() - 1; // initialize p
q1 = signedMin.udiv(nc); // initialize q1 = 2p/nc
r1 = signedMin - q1*nc; // initialize r1 = rem(2p,nc)
OpenPOWER on IntegriCloud