[PATCH] D96979: [DSE] Extending IsGuaranteedLoopInvariant to support a GetElementPtrInst defined in the entry block

Matteo Favaro via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 18 15:50:59 PST 2021


fvrmatteo updated this revision to Diff 324800.
fvrmatteo added a comment.

I tried to update the patch to execute the entry block check on the incoming pointer (if it's an instruction) as first thing in the **IsGuaranteedLoopInvariant** function.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D96979/new/

https://reviews.llvm.org/D96979

Files:
  llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp


Index: llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
+++ llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
@@ -1911,6 +1911,11 @@
     };
 
     Ptr = Ptr->stripPointerCasts();
+    if (auto *I = dyn_cast<Instruction>(Ptr)) {
+      if (I->getParent() == &I->getFunction()->getEntryBlock()) {
+        return true;
+      }
+    }
     if (auto *GEP = dyn_cast<GEPOperator>(Ptr)) {
       return IsGuaranteedLoopInvariantBase(GEP->getPointerOperand()) &&
              GEP->hasAllConstantIndices();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D96979.324800.patch
Type: text/x-patch
Size: 631 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210218/f9e1168f/attachment.bin>


More information about the llvm-commits mailing list