[llvm] r371973 - [SLPVectorizer] Don't dereference a dyn_cast result. NFCI.

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 16 03:35:09 PDT 2019


Author: rksimon
Date: Mon Sep 16 03:35:09 2019
New Revision: 371973

URL: http://llvm.org/viewvc/llvm-project?rev=371973&view=rev
Log:
[SLPVectorizer] Don't dereference a dyn_cast result. NFCI.

The static analyzer is warning about potential null dereferences of dyn_cast<> results - in these cases we can safely use cast<> directly as we know that these cases should all be the correct type, which is why its working atm and anyway cast<> will assert if they aren't.

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

Modified: llvm/trunk/lib/Transforms/Vectorize/SLPVectorizer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Vectorize/SLPVectorizer.cpp?rev=371973&r1=371972&r2=371973&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Vectorize/SLPVectorizer.cpp (original)
+++ llvm/trunk/lib/Transforms/Vectorize/SLPVectorizer.cpp Mon Sep 16 03:35:09 2019
@@ -2273,7 +2273,7 @@ void BoUpSLP::buildTree_rec(ArrayRef<Val
                 (unsigned) Instruction::ShuffleVector : S.getOpcode();
   switch (ShuffleOrOp) {
     case Instruction::PHI: {
-      PHINode *PH = dyn_cast<PHINode>(VL0);
+      auto *PH = cast<PHINode>(VL0);
 
       // Check for terminator values (e.g. invoke).
       for (unsigned j = 0; j < VL.size(); ++j)
@@ -2713,7 +2713,7 @@ void BoUpSLP::buildTree_rec(ArrayRef<Val
         ValueList Operands;
         // Prepare the operand vector.
         for (Value *V : VL) {
-          CallInst *CI2 = dyn_cast<CallInst>(V);
+          auto *CI2 = cast<CallInst>(V);
           Operands.push_back(CI2->getArgOperand(i));
         }
         buildTree_rec(Operands, Depth + 1, {TE, i});
@@ -3676,7 +3676,7 @@ Value *BoUpSLP::vectorizeTree(TreeEntry
       E->isAltShuffle() ? (unsigned)Instruction::ShuffleVector : E->getOpcode();
   switch (ShuffleOrOp) {
     case Instruction::PHI: {
-      PHINode *PH = dyn_cast<PHINode>(VL0);
+      auto *PH = cast<PHINode>(VL0);
       Builder.SetInsertPoint(PH->getParent()->getFirstNonPHI());
       Builder.SetCurrentDebugLocation(PH->getDebugLoc());
       PHINode *NewPhi = Builder.CreatePHI(VecTy, PH->getNumIncomingValues());
@@ -3800,7 +3800,7 @@ Value *BoUpSLP::vectorizeTree(TreeEntry
         return E->VectorizedValue;
       }
 
-      CastInst *CI = dyn_cast<CastInst>(VL0);
+      auto *CI = cast<CastInst>(VL0);
       Value *V = Builder.CreateCast(CI->getOpcode(), InVec, VecTy);
       if (NeedToShuffleReuses) {
         V = Builder.CreateShuffleVector(V, UndefValue::get(VecTy),




More information about the llvm-commits mailing list