From: David Majnemer Date: Sat, 20 Dec 2014 04:45:33 +0000 (+0000) Subject: InstSimplify: Don't bother if getScalarSizeInBits returns zero X-Git-Url: http://plrg.eecs.uci.edu/git/?p=oota-llvm.git;a=commitdiff_plain;h=821c6f765adbc3079a21ad91d10726cbf8c4cb1b 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 --- diff --git a/lib/Analysis/InstructionSimplify.cpp b/lib/Analysis/InstructionSimplify.cpp index 7d8b668be03..56e7a094976 100644 --- a/lib/Analysis/InstructionSimplify.cpp +++ b/lib/Analysis/InstructionSimplify.cpp @@ -3152,14 +3152,15 @@ static Value *SimplifySelectInst(Value *CondVal, Value *TrueVal, if (isa(FalseVal)) // select C, X, undef -> X return TrueVal; - if (const auto *ICI = dyn_cast(CondVal)) { + const auto *ICI = dyn_cast(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())) {