[llvm-commits] [llvm] r64917 - /llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp

Dan Gohman gohman at apple.com
Wed Feb 18 08:54:33 PST 2009


Author: djg
Date: Wed Feb 18 10:54:33 2009
New Revision: 64917

URL: http://llvm.org/viewvc/llvm-project?rev=64917&view=rev
Log:
Simplify by using dyn_cast instead of isa and cast.

Modified:
    llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp?rev=64917&r1=64916&r2=64917&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp Wed Feb 18 10:54:33 2009
@@ -582,18 +582,17 @@
   // For now, only analyze loops with a constant start value, so that
   // we can easily determine if the start value is not a maximum value
   // which would wrap on the first iteration.
-  const Value *InitialVal = PN->getIncomingValue(IncomingEdge);
-  if (!isa<ConstantInt>(InitialVal))
+  const ConstantInt *InitialVal =
+    dyn_cast<ConstantInt>(PN->getIncomingValue(IncomingEdge));
+  if (!InitialVal)
     return 0;
 
   // The original induction variable will start at some non-max value,
   // it counts up by one, and the loop iterates only while it remans
   // less than some value in the same type. As such, it will never wrap.
-  if (isSigned &&
-      !cast<ConstantInt>(InitialVal)->getValue().isMaxSignedValue())
+  if (isSigned && !InitialVal->getValue().isMaxSignedValue())
     NoSignedWrap = true;
-  else if (!isSigned &&
-           !cast<ConstantInt>(InitialVal)->getValue().isMaxValue())
+  else if (!isSigned && !InitialVal->getValue().isMaxValue())
     NoUnsignedWrap = true;
   return PN;
 }





More information about the llvm-commits mailing list