mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-12 13:38:21 +00:00
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:
@ -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;
|
||||
}
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user