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

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 18 09:47:23 PDT 2020


fhahn updated this revision to Diff 251109.
fhahn marked 3 inline comments as done.
fhahn added a comment.

Remove unnecessary checks, do not skip the checks later on.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76228

Files:
  llvm/lib/Analysis/ValueTracking.cpp


Index: llvm/lib/Analysis/ValueTracking.cpp
===================================================================
--- llvm/lib/Analysis/ValueTracking.cpp
+++ llvm/lib/Analysis/ValueTracking.cpp
@@ -597,17 +597,10 @@
   if (Inv->getParent() != CxtI->getParent())
     return false;
 
-  // If we have a dom tree, then we now know that the assume doesn't dominate
-  // the other instruction.  If we don't have a dom tree then we can check if
-  // 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 Inv and CtxI are in the same block, check if the assume (Inv) is first
+  // in the BB.
+  if (Inv->comesBefore(CxtI))
+    return true;
 
   // Don't let an assume affect itself - this would cause the problems
   // `isEphemeralValueOf` is trying to prevent, and it would also make


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D76228.251109.patch
Type: text/x-patch
Size: 1102 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200318/537700a8/attachment.bin>


More information about the llvm-commits mailing list