[PATCH] D11051: Swap loop invariant GEP with loop variant GEP to allow more LICM.

hfinkel@anl.gov via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 10 00:05:28 PDT 2015


hfinkel added inline comments.

================
Comment at: lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp:758
@@ +757,3 @@
+      L && L->isLoopInvariant(ResultPtr) &&
+      NumOfCommonBaseGEPs[std::pair<Value *, Loop *>(ResultPtr, L)] == 1;
+  Value *FirstResult = nullptr;
----------------
You shouldn't need to pre-compute this, you can examine the use list if necessary, something like this:

  auto TooManyUsesInLoop = [](Value *V, Loop *L) {
    int UsesInLoop = 0;
    for (User *U : V->users()) {
      if (Instruction *User = dyn_cast<Instruction>(U))
        if (L->contains(User))
          if (++UsesInLoop > 1)
            return true;

      return false;
    }
  };


================
Comment at: lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp:803
@@ +802,3 @@
+  // If we created a GEP with constant index, and the base is loop invariant,
+  // Then we swap the first one with it, so LICM could move constant GEP out
+  // later.
----------------
Then -> then
could move -> can move

================
Comment at: lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp:1060
@@ +1059,3 @@
+          if (GetElementPtrInst *GEP = dyn_cast<GetElementPtrInst>(I++))
+            NumOfCommonBaseGEPs[std::pair<Value *, Loop *>(GEP->getOperand(0),
+                                                           L)]++;
----------------
This seems unnecessary (see above).



Repository:
  rL LLVM

http://reviews.llvm.org/D11051





More information about the llvm-commits mailing list