diff options
author | Dan Gohman <gohman@apple.com> | 2009-04-25 17:05:40 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2009-04-25 17:05:40 +0000 |
commit | 91ae1e7f8d5ab7e62137da6671f4feb51c56c7ad (patch) | |
tree | 7871a90ca0cb7812f7fe9a280dc3c92ea1adc2a5 /lib | |
parent | b2d71d700e4d48b97f13c07da9cb9b78019dfad7 (diff) | |
download | external_llvm-91ae1e7f8d5ab7e62137da6671f4feb51c56c7ad.zip external_llvm-91ae1e7f8d5ab7e62137da6671f4feb51c56c7ad.tar.gz external_llvm-91ae1e7f8d5ab7e62137da6671f4feb51c56c7ad.tar.bz2 |
Handle ands with 0 and shifts by 0 correctly. These aren't
common, but indvars shouldn't crash on them. This fixes PR4054.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70051 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Analysis/ScalarEvolution.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/Analysis/ScalarEvolution.cpp b/lib/Analysis/ScalarEvolution.cpp index 409bad9..495290d 100644 --- a/lib/Analysis/ScalarEvolution.cpp +++ b/lib/Analysis/ScalarEvolution.cpp @@ -1754,6 +1754,8 @@ SCEVHandle ScalarEvolution::createSCEV(Value *V) { // For an expression like x&255 that merely masks off the high bits, // use zext(trunc(x)) as the SCEV expression. if (ConstantInt *CI = dyn_cast<ConstantInt>(U->getOperand(1))) { + if (CI->isNullValue()) + return getSCEV(U->getOperand(1)); const APInt &A = CI->getValue(); unsigned Ones = A.countTrailingOnes(); if (APIntOps::isMask(Ones, A)) @@ -1818,10 +1820,15 @@ SCEVHandle ScalarEvolution::createSCEV(Value *V) { if (Instruction *L = dyn_cast<Instruction>(U->getOperand(0))) if (L->getOpcode() == Instruction::Shl && L->getOperand(1) == U->getOperand(1)) { - uint64_t Amt = getTypeSizeInBits(U->getType()) - CI->getZExtValue(); + unsigned BitWidth = getTypeSizeInBits(U->getType()); + uint64_t Amt = BitWidth - CI->getZExtValue(); + if (Amt == BitWidth) + return getSCEV(L->getOperand(0)); // shift by zero --> noop + if (Amt > BitWidth) + return getIntegerSCEV(0, U->getType()); // value is undefined return getSignExtendExpr(getTruncateExpr(getSCEV(L->getOperand(0)), - IntegerType::get(Amt)), + IntegerType::get(Amt)), U->getType()); } break; |