PR14904: Segmentation fault running pass 'Recognize loop idioms'
[oota-llvm.git] / lib / Transforms / Scalar / LoopIdiomRecognize.cpp
index c4f90125ac5a05e1d4f7cda2d05d511c05615ccd..8258719a0200b3d090b4057250b714e01ac59b41 100644 (file)
@@ -407,7 +407,7 @@ bool NclPopcountRecognize::detectIdiom(Instruction *&CntInst,
 
   // step 2: detect instructions corresponding to "x2 = x1 & (x1 - 1)"
   {
-    if (DefX2->getOpcode() != Instruction::And)
+    if (!DefX2 || DefX2->getOpcode() != Instruction::And)
       return false;
 
     BinaryOperator *SubOneOp;