[SCEV] Use `SCEV::isAllOnesValue` directly; NFC.
authorSanjoy Das <sanjoy@playingwithpointers.com>
Tue, 13 Oct 2015 23:28:31 +0000 (23:28 +0000)
committerSanjoy Das <sanjoy@playingwithpointers.com>
Tue, 13 Oct 2015 23:28:31 +0000 (23:28 +0000)
Instead of `dyn_cast` ing to `SCEVConstant` and checking the contained
`ConstantInteger.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@250251 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/ScalarEvolution.cpp

index a1a4f2501fa1941fa841b227dddfa2bef5d067ac..7d52ca759d86d338b7ad839d8b620ccb57ae7f14 100644 (file)
@@ -7677,17 +7677,13 @@ bool ScalarEvolution::isImpliedCondOperands(ICmpInst::Predicate Pred,
 /// If Expr computes ~A, return A else return nullptr
 static const SCEV *MatchNotExpr(const SCEV *Expr) {
   const SCEVAddExpr *Add = dyn_cast<SCEVAddExpr>(Expr);
-  if (!Add || Add->getNumOperands() != 2) return nullptr;
-
-  const SCEVConstant *AddLHS = dyn_cast<SCEVConstant>(Add->getOperand(0));
-  if (!(AddLHS && AddLHS->getValue()->getValue().isAllOnesValue()))
+  if (!Add || Add->getNumOperands() != 2 ||
+      !Add->getOperand(0)->isAllOnesValue())
     return nullptr;
 
   const SCEVMulExpr *AddRHS = dyn_cast<SCEVMulExpr>(Add->getOperand(1));
-  if (!AddRHS || AddRHS->getNumOperands() != 2) return nullptr;
-
-  const SCEVConstant *MulLHS = dyn_cast<SCEVConstant>(AddRHS->getOperand(0));
-  if (!(MulLHS && MulLHS->getValue()->getValue().isAllOnesValue()))
+  if (!AddRHS || AddRHS->getNumOperands() != 2 ||
+      !AddRHS->getOperand(0)->isAllOnesValue())
     return nullptr;
 
   return AddRHS->getOperand(1);