Simplify some code
authorChris Lattner <sabre@nondot.org>
Wed, 10 Sep 2003 04:49:10 +0000 (04:49 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 10 Sep 2003 04:49:10 +0000 (04:49 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8426 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/InductionVariable.cpp

index 3ac934e42b1baf91a6b036585f5545e63ae71b1b..73e97a4a1142b7bf9441a260e38ad58c6d96260a 100644 (file)
 #include "Support/Debug.h"
 
 static bool isLoopInvariant(const Value *V, const Loop *L) {
-  if (isa<Constant>(V) || isa<Argument>(V) || isa<GlobalValue>(V))
-    return true;
-  
-  const Instruction *I = cast<Instruction>(V);
-  const BasicBlock *BB = I->getParent();
-
-  return !L->contains(BB);
+  if (const Instruction *I = dyn_cast<Instruction>(V))
+    return !L->contains(I->getParent());
+  // non-instructions all dominate instructions/blocks
+  return true;
 }
 
 enum InductionVariable::iType
@@ -45,7 +42,7 @@ InductionVariable::Classify(const Value *Start, const Value *Step,
   // Check for cannonical and simple linear expressions now...
   if (const ConstantInt *CStart = dyn_cast<ConstantInt>(Start))
     if (const ConstantInt *CStep = dyn_cast<ConstantInt>(Step)) {
-      if (CStart->equalsInt(0) && CStep->equalsInt(1))
+      if (CStart->isNullValue() && CStep->equalsInt(1))
         return Cannonical;
       else
         return SimpleLinear;