[PATCH] D76228: [ValueTracking] Use Inst::comesBefore in isValidAssumeForCtx (NFC).
Florian Hahn via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 16 05:53:11 PDT 2020
fhahn created this revision.
fhahn added reviewers: rnk, nikic, spatel.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.
D51664 <https://reviews.llvm.org/D51664> added Instruction::comesBefore which should provide better
performance than the manual check.
Repository:
rG LLVM Github Monorepo
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
@@ -600,14 +600,8 @@
// 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 (!DT && Inv->getParent() == CxtI->getParent())
+ return Inv->comesBefore(CxtI);
// 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.250542.patch
Type: text/x-patch
Size: 977 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200316/6afa4ded/attachment.bin>
More information about the llvm-commits
mailing list