[PATCH] D76228: [ValueTracking] Use Inst::comesBefore in isValidAssumeForCtx (NFC).

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 16 06:26:26 PDT 2020


nikic added inline comments.


================
Comment at: llvm/lib/Analysis/ValueTracking.cpp:603
   // the assume is first in the BB.
-  if (!DT) {
-    // Search forward from the assume until we reach the context (or the end
-    // of the block); the common case is that the assume will come first.
-    for (auto I = std::next(BasicBlock::const_iterator(Inv)),
-         IE = Inv->getParent()->end(); I != IE; ++I)
-      if (&*I == CxtI)
-        return true;
-  }
+  if (!DT && Inv->getParent() == CxtI->getParent())
+    return Inv->comesBefore(CxtI);
----------------
This condition is redundant, it's already checked above.


================
Comment at: llvm/lib/Analysis/ValueTracking.cpp:604
+  if (!DT && Inv->getParent() == CxtI->getParent())
+    return Inv->comesBefore(CxtI);
 
----------------
This should be `if (Inv->comesBefore(CxtI)) return true`, otherwise the reverse-direction scan below will be skipped.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76228/new/

https://reviews.llvm.org/D76228





More information about the llvm-commits mailing list