[llvm] r224675 - InstSimplify: Don't bother if getScalarSizeInBits returns zero

David Majnemer david.majnemer at gmail.com
Fri Dec 19 20:45:33 PST 2014


Author: majnemer
Date: Fri Dec 19 22:45:33 2014
New Revision: 224675

URL: http://llvm.org/viewvc/llvm-project?rev=224675&view=rev
Log:
InstSimplify: Don't bother if getScalarSizeInBits returns zero

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

Modified:
    llvm/trunk/lib/Analysis/InstructionSimplify.cpp

Modified: llvm/trunk/lib/Analysis/InstructionSimplify.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/InstructionSimplify.cpp?rev=224675&r1=224674&r2=224675&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/InstructionSimplify.cpp (original)
+++ llvm/trunk/lib/Analysis/InstructionSimplify.cpp Fri Dec 19 22:45:33 2014
@@ -3152,14 +3152,15 @@ static Value *SimplifySelectInst(Value *
   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())) {





More information about the llvm-commits mailing list