Fix a bug that clobbered the step value on some inputs
authorChris Lattner <sabre@nondot.org>
Wed, 5 Dec 2001 06:32:30 +0000 (06:32 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 5 Dec 2001 06:32:30 +0000 (06:32 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1416 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/InductionVariable.cpp

index a340a771963159c019276aad0c4703a553efc772..d88c9cfc683c4c0b8147100bd1d1dc57328ec832 100644 (file)
@@ -69,6 +69,10 @@ InductionVariable::InductionVariable(PHINode *P, cfg::LoopInfo *LoopInfo) {
   //
   if (Phi->getNumIncomingValues() != 2) return;
 
+  // FIXME: Handle FP induction variables.
+  if (Phi->getType() == Type::FloatTy || Phi->getType() == Type::DoubleTy)
+    return;
+
   // If we have loop information, make sure that this PHI node is in the header
   // of a loop...
   //
@@ -140,11 +144,10 @@ InductionVariable::InductionVariable(PHINode *P, cfg::LoopInfo *LoopInfo) {
           Step = (Value*)StepE.Offset;
         else
           Step = Constant::getNullConstant(Step->getType());
+        const Type *ETy = Phi->getType();
+        if (ETy->isPointerType()) ETy = Type::ULongTy;
+        Step  = (Value*)(StepE.Offset ? StepE.Offset : ConstantInt::get(ETy,0));
       }
-
-      const Type *ETy = Phi->getType();
-      if (ETy->isPointerType()) ETy = Type::ULongTy;
-      Step  = (Value*)(StepE.Offset ? StepE.Offset : ConstantInt::get(ETy, 0));
     }
   }