From 75dc59c9a3ff3b040700b8c7ae11f3bd50bec29b Mon Sep 17 00:00:00 2001 From: Philip Reames Date: Mon, 25 Jan 2016 23:37:53 +0000 Subject: [PATCH] [GVN] Rearrange code to make local vs non-local cases more obvious [NFCI] llvm-svn: 258747 --- lib/Transforms/Scalar/GVN.cpp | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/lib/Transforms/Scalar/GVN.cpp b/lib/Transforms/Scalar/GVN.cpp index e0b1c9d2535..bbffbb0be75 100644 --- a/lib/Transforms/Scalar/GVN.cpp +++ b/lib/Transforms/Scalar/GVN.cpp @@ -1895,6 +1895,23 @@ bool GVN::processLoad(LoadInst *L) { MemDepResult Dep = MD->getDependency(L); const DataLayout &DL = L->getModule()->getDataLayout(); + // If it is defined in another block, try harder. + if (Dep.isNonLocal()) + return processNonLocalLoad(L); + + // Only handle the local case below + if (!Dep.isDef() && !Dep.isClobber()) { + // This might be a NonFuncLocal or an Unknown + DEBUG( + // fast print dep, using operator<< on instruction is too slow. + dbgs() << "GVN: load "; + L->printAsOperand(dbgs()); + dbgs() << " has unknown dependence\n"; + ); + return false; + } + + // If we have a clobber and target data is around, see if this is a clobber // that we can fix up through code synthesis. if (Dep.isClobber()) { @@ -1966,19 +1983,7 @@ bool GVN::processLoad(LoadInst *L) { return false; } - // If it is defined in another block, try harder. - if (Dep.isNonLocal()) - return processNonLocalLoad(L); - - if (!Dep.isDef()) { - DEBUG( - // fast print dep, using operator<< on instruction is too slow. - dbgs() << "GVN: load "; - L->printAsOperand(dbgs()); - dbgs() << " has unknown dependence\n"; - ); - return false; - } + assert(Dep.isDef() && "expected from control flow"); Instruction *DepInst = Dep.getInst(); Value *AvailableValue = nullptr;