[llvm] r243167 - Remove unnecessary null check. NFC.

Duncan P. N. Exon Smith dexonsmith at apple.com
Mon Jul 27 11:34:49 PDT 2015


> On 2015-Jul-24, at 14:38, Pete Cooper <peter_cooper at apple.com> wrote:
> 
> Author: pete
> Date: Fri Jul 24 16:38:01 2015
> New Revision: 243167
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=243167&view=rev
> Log:
> Remove unnecessary null check.  NFC.
> 
> Since both places which set this variable do so with dyn_cast, and not
> dyn_cast_or_null, its impossible to get a nullptr here, so we can remove
> the check.
> 

But `dyn_cast` will return null if the cast fails.  If you're sure
the cast won't fail, you should just use `cast`.

> Modified:
>    llvm/trunk/lib/Transforms/Scalar/LoopInterchange.cpp
> 
> Modified: llvm/trunk/lib/Transforms/Scalar/LoopInterchange.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopInterchange.cpp?rev=243167&r1=243166&r2=243167&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Transforms/Scalar/LoopInterchange.cpp (original)
> +++ llvm/trunk/lib/Transforms/Scalar/LoopInterchange.cpp Fri Jul 24 16:38:01 2015
> @@ -817,9 +817,6 @@ bool LoopInterchangeLegality::currentLim
>     InnerIndexVarInc =
>         dyn_cast<Instruction>(InnerInductionVar->getIncomingValue(0));
> 
> -  if (!InnerIndexVarInc)
> -    return true;
> -
>   // Since we split the inner loop latch on this induction variable. Make sure
>   // we do not have any instruction between the induction variable and branch
>   // instruction.
> 
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits





More information about the llvm-commits mailing list