Fix a minor bug which resulted in intermediate calculations
authorDan Gohman <gohman@apple.com>
Wed, 4 Aug 2010 19:52:50 +0000 (19:52 +0000)
committerDan Gohman <gohman@apple.com>
Wed, 4 Aug 2010 19:52:50 +0000 (19:52 +0000)
using wider types than are necessary.

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

lib/Analysis/ScalarEvolution.cpp

index 1dc8e83b1248ea4caa606f28991826a4053947ea..9aaafafe052342a5b09a265b2cb8eeb72a8227b5 100644 (file)
@@ -1896,7 +1896,7 @@ const SCEV *ScalarEvolution::getUDivExpr(const SCEV *LHS,
       // TODO: Generalize this to non-constants by using known-bits information.
       const Type *Ty = LHS->getType();
       unsigned LZ = RHSC->getValue()->getValue().countLeadingZeros();
-      unsigned MaxShiftAmt = getTypeSizeInBits(Ty) - LZ;
+      unsigned MaxShiftAmt = getTypeSizeInBits(Ty) - LZ - 1;
       // For non-power-of-two values, effectively round the value up to the
       // nearest power of two.
       if (!RHSC->getValue()->getValue().isPowerOf2())