make m_ConstantInt(int64_t) safely match ConstantInt's that are larger than i64.

This fixes an instcombine crash on PR3235.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61775 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner
2009-01-05 23:45:50 +00:00
parent 78eb6ad633
commit 06ebbcc71d
2 changed files with 37 additions and 1 deletions

View File

@ -57,7 +57,16 @@ struct constantint_ty {
template<typename ITy>
bool match(ITy *V) {
return isa<ConstantInt>(V) && cast<ConstantInt>(V)->getSExtValue() == Val;
if (const ConstantInt *CI = dyn_cast<ConstantInt>(V)) {
const APInt &CIV = CI->getValue();
if (Val > 0)
return CIV == Val;
// If Val is negative, and CI is shorter than it, truncate to the right
// number of bits. If it is larger, then we have to sign extend. Just
// compare their negated values.
return -CIV == -Val;
}
return false;
}
};