InstSimplify: Don't bother if getScalarSizeInBits returns zero

getScalarSizeInBits returns zero when the comparison operands are not
integral.  No functionality change intended.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224675 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
David Majnemer 2014-12-20 04:45:33 +00:00
parent f666c0549e
commit 821c6f765a

View File

@ -3152,14 +3152,15 @@ static Value *SimplifySelectInst(Value *CondVal, Value *TrueVal,
if (isa<UndefValue>(FalseVal)) // select C, X, undef -> X
return TrueVal;
if (const auto *ICI = dyn_cast<ICmpInst>(CondVal)) {
const auto *ICI = dyn_cast<ICmpInst>(CondVal);
unsigned BitWidth = TrueVal->getType()->getScalarSizeInBits();
if (ICI && BitWidth) {
ICmpInst::Predicate Pred = ICI->getPredicate();
APInt MinSignedValue =
APInt::getSignBit(TrueVal->getType()->getScalarSizeInBits());
APInt MinSignedValue = APInt::getSignBit(BitWidth);
Value *X;
const APInt *Y;
bool IsBitTest = false;
bool TrueWhenUnset;
bool IsBitTest = false;
if (ICmpInst::isEquality(Pred) &&
match(ICI->getOperand(0), m_And(m_Value(X), m_APInt(Y))) &&
match(ICI->getOperand(1), m_Zero())) {