[cgp] Minor code improvement - reuse an existing named helper [NFC]
authorPhilip Reames <listmail@philipreames.com>
Fri, 26 Feb 2021 19:50:40 +0000 (11:50 -0800)
committerPhilip Reames <listmail@philipreames.com>
Fri, 26 Feb 2021 19:51:32 +0000 (11:51 -0800)
llvm/lib/CodeGen/CodeGenPrepare.cpp

index f81d097..ed83fad 100644 (file)
@@ -1290,9 +1290,9 @@ bool CodeGenPrepare::replaceMathCmpWithIntrinsic(BinaryOperator *BO,
     const BasicBlock *Latch = L->getLoopLatch();
     if (PN->getIncomingValueForBlock(Latch) != BO)
       return false;
-    if (auto *Step = dyn_cast<Instruction>(BO->getOperand(1)))
-      if (L->contains(Step->getParent()))
-        return false;
+    if (!L->isLoopInvariant(BO->getOperand(1)))
+      // Avoid complexities w/loop varying steps.
+      return false;
     // IV increment may have other users than the IV. We do not want to make
     // dominance queries to analyze the legality of moving it towards the cmp,
     // so just check that there is no other users.