[llvm] r185168 - LoopVectorize: Pull dyn_cast into setDebugLocFromInst

Arnold Schwaighofer aschwaighofer at apple.com
Fri Jun 28 10:14:48 PDT 2013


Author: arnolds
Date: Fri Jun 28 12:14:48 2013
New Revision: 185168

URL: http://llvm.org/viewvc/llvm-project?rev=185168&view=rev
Log:
LoopVectorize: Pull dyn_cast into setDebugLocFromInst

Modified:
    llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp

Modified: llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp?rev=185168&r1=185167&r2=185168&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp (original)
+++ llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp Fri Jun 28 12:14:48 2013
@@ -347,8 +347,8 @@ static Instruction *getDebugLocFromInstO
 
 /// \brief Set the debug location in the builder using the debug location in the
 /// instruction.
-static void setDebugLocFromInst(IRBuilder<> &B, const Instruction *Inst) {
-  if (Inst)
+static void setDebugLocFromInst(IRBuilder<> &B, const Value *Ptr) {
+  if (const Instruction *Inst = dyn_cast_or_null<Instruction>(Ptr))
     B.SetCurrentDebugLocation(Inst->getDebugLoc());
   else
     B.SetCurrentDebugLocation(DebugLoc());
@@ -1267,7 +1267,7 @@ void InnerLoopVectorizer::vectorizeMemor
   } else {
     // Use the induction element ptr.
     assert(isa<PHINode>(Ptr) && "Invalid induction ptr");
-    setDebugLocFromInst(Builder, cast<Instruction>(Ptr));
+    setDebugLocFromInst(Builder, Ptr);
     VectorParts &PtrVal = getVectorValue(Ptr);
     Ptr = Builder.CreateExtractElement(PtrVal[0], Zero);
   }
@@ -2046,8 +2046,7 @@ InnerLoopVectorizer::vectorizeLoop(LoopV
     LoopVectorizationLegality::ReductionDescriptor RdxDesc =
     (*Legal->getReductionVars())[RdxPhi];
 
-    setDebugLocFromInst(Builder,
-                        dyn_cast<Instruction>((Value*)RdxDesc.StartValue));
+    setDebugLocFromInst(Builder, RdxDesc.StartValue);
 
     // We need to generate a reduction vector from the incoming scalar.
     // To do so, we need to generate the 'identity' vector and overide
@@ -2122,7 +2121,7 @@ InnerLoopVectorizer::vectorizeLoop(LoopV
     // Reduce all of the unrolled parts into a single vector.
     Value *ReducedPartRdx = RdxParts[0];
     unsigned Op = getReductionBinOp(RdxDesc.Kind);
-    setDebugLocFromInst(Builder, dyn_cast<Instruction>(ReducedPartRdx));
+    setDebugLocFromInst(Builder, ReducedPartRdx);
     for (unsigned part = 1; part < UF; ++part) {
       if (Op != Instruction::ICmp && Op != Instruction::FCmp)
         ReducedPartRdx = Builder.CreateBinOp((Instruction::BinaryOps)Op,





More information about the llvm-commits mailing list