[LSR] Minor code style improvement [nfc]
authorPhilip Reames <preames@rivosinc.com>
Fri, 17 Mar 2023 14:50:26 +0000 (07:50 -0700)
committerPhilip Reames <listmail@philipreames.com>
Fri, 17 Mar 2023 14:50:59 +0000 (07:50 -0700)
llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp

index e5da065..73b8a40 100644 (file)
@@ -6706,8 +6706,8 @@ canFoldTermCondOfLoop(Loop *L, ScalarEvolution &SE, DominatorTree &DT,
   BranchInst *BI = cast<BranchInst>(LoopLatch->getTerminator());
   if (BI->isUnconditional())
     return std::nullopt;
-  Value *TermCond = BI->getCondition();
-  if (!isa<ICmpInst>(TermCond) || !cast<ICmpInst>(TermCond)->isEquality()) {
+  auto *TermCond = dyn_cast<ICmpInst>(BI->getCondition());
+  if (!TermCond || !TermCond->isEquality()) {
     LLVM_DEBUG(dbgs() << "Cannot fold on branching condition that is not an "
                          "ICmpInst::eq / ICmpInst::ne\n");
     return std::nullopt;