[PATCH] D135369: [DSE] Relax constraint on isGuaranteedLoopInvariant
luxufan via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 6 08:09:56 PDT 2022
StephenFan created this revision.
StephenFan added reviewers: nikic, fhahn.
Herald added a subscriber: hiraditya.
Herald added a project: All.
StephenFan requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
If the location ptr to be killed is in no loop and the Function does not
have irreducible loops, then we can regard it as loop invariant.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D135369
Files:
llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
llvm/test/Transforms/DeadStoreElimination/multiblock-loops.ll
llvm/test/Transforms/DeadStoreElimination/multiblock-malloc-free.ll
Index: llvm/test/Transforms/DeadStoreElimination/multiblock-malloc-free.ll
===================================================================
--- llvm/test/Transforms/DeadStoreElimination/multiblock-malloc-free.ll
+++ llvm/test/Transforms/DeadStoreElimination/multiblock-malloc-free.ll
@@ -170,7 +170,6 @@
; CHECK-NEXT: br i1 true, label [[BB2:%.*]], label [[BB3:%.*]]
; CHECK: bb2:
; CHECK-NEXT: [[M:%.*]] = call noalias ptr @malloc(i64 10)
-; CHECK-NEXT: store i8 1, ptr [[M]], align 1
; CHECK-NEXT: br label [[BB3]]
; CHECK: bb3:
; CHECK-NEXT: [[R:%.*]] = phi ptr [ null, [[BB1:%.*]] ], [ [[M]], [[BB2]] ]
Index: llvm/test/Transforms/DeadStoreElimination/multiblock-loops.ll
===================================================================
--- llvm/test/Transforms/DeadStoreElimination/multiblock-loops.ll
+++ llvm/test/Transforms/DeadStoreElimination/multiblock-loops.ll
@@ -846,7 +846,6 @@
; CHECK-NEXT: br label [[FIRST:%.*]]
; CHECK: first:
; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds [10 x i16], ptr @x, i16 0, i32 [[I:%.*]]
-; CHECK-NEXT: store i16 1, ptr [[ARRAYIDX]], align 1
; CHECK-NEXT: br label [[DO_BODY:%.*]]
; CHECK: do.body:
; CHECK-NEXT: [[I_0:%.*]] = phi i16 [ 0, [[FIRST]] ], [ [[INC:%.*]], [[DO_BODY]] ]
Index: llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
+++ llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
@@ -1199,6 +1199,7 @@
if (Current->getParent() == KillingDef->getParent())
return true;
const Loop *CurrentLI = LI.getLoopFor(Current->getParent());
+
if (!ContainsIrreducibleLoops && CurrentLI &&
CurrentLI == LI.getLoopFor(KillingDef->getParent()))
return true;
@@ -1216,7 +1217,7 @@
Ptr = GEP->getPointerOperand()->stripPointerCasts();
if (auto *I = dyn_cast<Instruction>(Ptr))
- return I->getParent()->isEntryBlock();
+ return !ContainsIrreducibleLoops && !LI.getLoopFor(I->getParent());
return true;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D135369.465745.patch
Type: text/x-patch
Size: 2128 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221006/1ef8e4c7/attachment.bin>
More information about the llvm-commits
mailing list