From: Simon Pilgrim Date: Mon, 16 Sep 2019 10:35:09 +0000 (+0000) Subject: [SLPVectorizer] Don't dereference a dyn_cast result. NFCI. X-Git-Tag: llvmorg-11-init~9144 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ae625d70cdb36485de9429b1ea26ae74e535a053;p=platform%2Fupstream%2Fllvm.git [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. llvm-svn: 371973 --- diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp index c18972c..a9d8649 100644 --- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp +++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp @@ -2273,7 +2273,7 @@ void BoUpSLP::buildTree_rec(ArrayRef VL, unsigned Depth, (unsigned) Instruction::ShuffleVector : S.getOpcode(); switch (ShuffleOrOp) { case Instruction::PHI: { - PHINode *PH = dyn_cast(VL0); + auto *PH = cast(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 VL, unsigned Depth, ValueList Operands; // Prepare the operand vector. for (Value *V : VL) { - CallInst *CI2 = dyn_cast(V); + auto *CI2 = cast(V); Operands.push_back(CI2->getArgOperand(i)); } buildTree_rec(Operands, Depth + 1, {TE, i}); @@ -3676,7 +3676,7 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E) { E->isAltShuffle() ? (unsigned)Instruction::ShuffleVector : E->getOpcode(); switch (ShuffleOrOp) { case Instruction::PHI: { - PHINode *PH = dyn_cast(VL0); + auto *PH = cast(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 *E) { return E->VectorizedValue; } - CastInst *CI = dyn_cast(VL0); + auto *CI = cast(VL0); Value *V = Builder.CreateCast(CI->getOpcode(), InVec, VecTy); if (NeedToShuffleReuses) { V = Builder.CreateShuffleVector(V, UndefValue::get(VecTy),