SeparateConstOffsetFromGEP::lowerToSingleIndexGEPs - don't use dyn_cast_or_null....
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Tue, 15 Dec 2020 17:15:06 +0000 (17:15 +0000)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Tue, 15 Dec 2020 17:27:25 +0000 (17:27 +0000)
ResultPtr is guaranteed to be non-null - and using dyn_cast_or_null causes unnecessary static analyzer warnings.

We can't say the same for FirstResult AFAICT, so keep dyn_cast_or_null for that.

llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp

index 558bace..f216956 100644 (file)
@@ -902,8 +902,8 @@ void SeparateConstOffsetFromGEP::lowerToSingleIndexGEPs(
   // If we created a GEP with constant index, and the base is loop invariant,
   // then we swap the first one with it, so LICM can move constant GEP out
   // later.
-  GetElementPtrInst *FirstGEP = dyn_cast_or_null<GetElementPtrInst>(FirstResult);
-  GetElementPtrInst *SecondGEP = dyn_cast_or_null<GetElementPtrInst>(ResultPtr);
+  auto *FirstGEP = dyn_cast_or_null<GetElementPtrInst>(FirstResult);
+  auto *SecondGEP = dyn_cast<GetElementPtrInst>(ResultPtr);
   if (isSwapCandidate && isLegalToSwapOperand(FirstGEP, SecondGEP, L))
     swapGEPOperand(FirstGEP, SecondGEP);