[llvm-branch-commits] [llvm-branch] r276420 - Merging r276358, r276364, and r276368

Hans Wennborg via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Jul 22 07:12:11 PDT 2016


Author: hans
Date: Fri Jul 22 09:12:11 2016
New Revision: 276420

URL: http://llvm.org/viewvc/llvm-project?rev=276420&view=rev
Log:
Merging r276358, r276364, and r276368

------------------------------------------------------------------------
r276358 | spop | 2016-07-21 16:22:10 -0700 (Thu, 21 Jul 2016) | 6 lines

GVH-hoist: only clone GEPs (PR28606)

Do not clone stored values unless they are GEPs that are special cased to avoid
hoisting them without hoisting their associated ld/st.

Differential revision: https://reviews.llvm.org/D22652
------------------------------------------------------------------------

------------------------------------------------------------------------
r276364 | spop | 2016-07-21 16:32:39 -0700 (Thu, 21 Jul 2016) | 1 line

GVN-hoist: add missing check for all GEP operands available
------------------------------------------------------------------------

------------------------------------------------------------------------
r276368 | spop | 2016-07-21 17:07:01 -0700 (Thu, 21 Jul 2016) | 1 line

GVN-hoist: move check before mutating the IR
------------------------------------------------------------------------

Added:
    llvm/branches/release_39/test/Transforms/GVN/hoist-pr28606.ll
      - copied unchanged from r276358, llvm/trunk/test/Transforms/GVN/hoist-pr28606.ll
Modified:
    llvm/branches/release_39/   (props changed)
    llvm/branches/release_39/lib/Transforms/Scalar/GVNHoist.cpp
    llvm/branches/release_39/test/Transforms/GVN/pr28626.ll

Propchange: llvm/branches/release_39/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Jul 22 09:12:11 2016
@@ -1,3 +1,3 @@
 /llvm/branches/Apple/Pertwee:110850,110961
 /llvm/branches/type-system-rewrite:133420-134817
-/llvm/trunk:155241,275870,275879,275898,275935,275946,276181
+/llvm/trunk:155241,275870,275879,275898,275935,275946,276181,276358,276364,276368

Modified: llvm/branches/release_39/lib/Transforms/Scalar/GVNHoist.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_39/lib/Transforms/Scalar/GVNHoist.cpp?rev=276420&r1=276419&r2=276420&view=diff
==============================================================================
--- llvm/branches/release_39/lib/Transforms/Scalar/GVNHoist.cpp (original)
+++ llvm/branches/release_39/lib/Transforms/Scalar/GVNHoist.cpp Fri Jul 22 09:12:11 2016
@@ -596,21 +596,19 @@ public:
     if (auto *St = dyn_cast<StoreInst>(Repl)) {
       Gep = dyn_cast<GetElementPtrInst>(St->getPointerOperand());
       Val = dyn_cast<Instruction>(St->getValueOperand());
+      // Check that the stored value is available.
+      if (Val) {
+        if (isa<GetElementPtrInst>(Val)) {
+          // Check whether we can compute the GEP at HoistPt.
+          if (!allOperandsAvailable(Val, HoistPt))
+            return false;
+        } else if (!DT->dominates(Val->getParent(), HoistPt))
+          return false;
+      }
     }
 
-    if (!Gep)
-      return false;
-
-    // PHIs may only be inserted at the start of a block.
-    if (Val && isa<PHINode>(Val))
-      return false;
-
     // Check whether we can compute the Gep at HoistPt.
-    if (!allOperandsAvailable(Gep, HoistPt))
-      return false;
-
-    // Also check that the stored value is available.
-    if (Val && !allOperandsAvailable(Val, HoistPt))
+    if (!Gep || !allOperandsAvailable(Gep, HoistPt))
       return false;
 
     // Copy the gep before moving the ld/st.
@@ -618,8 +616,8 @@ public:
     ClonedGep->insertBefore(HoistPt->getTerminator());
     replaceUseWith(Repl, Gep, ClonedGep);
 
-    // Also copy Val.
-    if (Val) {
+    // Also copy Val when it is a GEP.
+    if (Val && isa<GetElementPtrInst>(Val)) {
       Instruction *ClonedVal = Val->clone();
       ClonedVal->insertBefore(HoistPt->getTerminator());
       replaceUseWith(Repl, Val, ClonedVal);

Modified: llvm/branches/release_39/test/Transforms/GVN/pr28626.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_39/test/Transforms/GVN/pr28626.ll?rev=276420&r1=276419&r2=276420&view=diff
==============================================================================
--- llvm/branches/release_39/test/Transforms/GVN/pr28626.ll (original)
+++ llvm/branches/release_39/test/Transforms/GVN/pr28626.ll Fri Jul 22 09:12:11 2016
@@ -38,5 +38,5 @@ if.end6:
 ; CHECK: %[[gep0:.*]] = getelementptr inbounds i1, i1* %[[load]], i64 0
 ; CHECK: store i1 %[[phi]], i1* %[[gep0]], align 4
 
-; CHECK: %[[gep1:.*]] = getelementptr inbounds i1, i1* %[[load]], i64 0
-; CHECK: store i1 %[[phi]], i1* %[[gep1]], align 4
+; Check that store instructions are hoisted.
+; CHECK-NOT: store
\ No newline at end of file




More information about the llvm-branch-commits mailing list