Make sure that we're dealing with a binary SCEVExpr when simplifying.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@157704 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Analysis/ScalarEvolution.cpp b/lib/Analysis/ScalarEvolution.cpp
index c45cc8d..b49c65f 100644
--- a/lib/Analysis/ScalarEvolution.cpp
+++ b/lib/Analysis/ScalarEvolution.cpp
@@ -5654,7 +5654,8 @@
       if (!RA)
         if (const SCEVAddExpr *AE = dyn_cast<SCEVAddExpr>(LHS))
           if (const SCEVMulExpr *ME = dyn_cast<SCEVMulExpr>(AE->getOperand(0)))
-            if (ME->getOperand(0)->isAllOnesValue()) {
+            if (AE->getNumOperands() == 2 && ME->getNumOperands() == 2 &&
+                ME->getOperand(0)->isAllOnesValue()) {
               RHS = AE->getOperand(1);
               LHS = ME->getOperand(1);
               Changed = true;