[llvm] r258747 - [GVN] Rearrange code to make local vs non-local cases more obvious [NFCI]

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 25 15:37:53 PST 2016


Author: reames
Date: Mon Jan 25 17:37:53 2016
New Revision: 258747

URL: http://llvm.org/viewvc/llvm-project?rev=258747&view=rev
Log:
[GVN] Rearrange code to make local vs non-local cases more obvious [NFCI]


Modified:
    llvm/trunk/lib/Transforms/Scalar/GVN.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/GVN.cpp?rev=258747&r1=258746&r2=258747&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/GVN.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/GVN.cpp Mon Jan 25 17:37:53 2016
@@ -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;




More information about the llvm-commits mailing list