Minor tweak to MDA
authorPhilip Reames <listmail@philipreames.com>
Fri, 13 Feb 2015 23:08:37 +0000 (23:08 +0000)
committerPhilip Reames <listmail@philipreames.com>
Fri, 13 Feb 2015 23:08:37 +0000 (23:08 +0000)
Two minor tweaks I noticed when reading through the code:
- No need to recompute begin() on every iteration.  We're not modifying the instructions in this loop.
- We can ignore PHINodes and Dbg intrinsics.  The current code does this anyways, but it will spend slightly more time doing so and will count towards the limit of instructions in the block.  It seems really silly to give up due the presence of PHIs...

Differential Revision: http://reviews.llvm.org/D7624

llvm-svn: 229175

llvm/lib/Analysis/MemoryDependenceAnalysis.cpp

index bcfea64..fa67aeb 100644 (file)
@@ -423,7 +423,9 @@ getPointerDependencyFrom(const AliasAnalysis::Location &MemLoc, bool isLoad,
   }
 
   // Walk backwards through the basic block, looking for dependencies.
-  while (ScanIt != BB->begin()) {
+  // We can stop before processing PHIs or dbg intrinsics.
+  const BasicBlock::iterator Begin(BB->getFirstNonPHIOrDbg());
+  while (ScanIt != Begin) {
     Instruction *Inst = --ScanIt;
 
     if (IntrinsicInst *II = dyn_cast<IntrinsicInst>(Inst))