Skip to content

Commit bb024c3

Browse files
committed
[DSE,MemorySSA] Remove short-cut to check if all paths are covered.
The post-order number early continue does not work in some cases, e.g. if a path from EarlierAccess to an exit includes a node that dominates EarlierAccess in a cycle. The short-cut only has very minor impact on compile-time, so it seems straight-forward to remove it for now: http://llvm-compile-time-tracker.com/compare.php?from=062412e79fcfedf2cf004433e42036b0333e3f83&to=d7386016a77ce1387bdbbf360f1de157faea9d31&stat=instructions Fixes PR47285.
1 parent fce035e commit bb024c3

File tree

2 files changed

+2
-9
lines changed

2 files changed

+2
-9
lines changed

llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2019,11 +2019,6 @@ struct DSEState {
20192019
if (PDT.dominates(CommonPred, EarlierAccess->getBlock())) {
20202020
SetVector<BasicBlock *> WorkList;
20212021

2022-
// EarlierAccess's post-order number provides an upper bound of the
2023-
// blocks on a path starting at EarlierAccess.
2024-
unsigned UpperBound =
2025-
PostOrderNumbers.find(EarlierAccess->getBlock())->second;
2026-
20272022
// If CommonPred is null, there are multiple exits from the function.
20282023
// They all have to be added to the worklist.
20292024
if (CommonPred)
@@ -2048,10 +2043,6 @@ struct DSEState {
20482043
if (!DT.isReachableFromEntry(Current))
20492044
continue;
20502045

2051-
unsigned CPO = PostOrderNumbers.find(Current)->second;
2052-
// Current block is not on a path starting at EarlierAccess.
2053-
if (CPO > UpperBound)
2054-
continue;
20552046
for (BasicBlock *Pred : predecessors(Current))
20562047
WorkList.insert(Pred);
20572048

llvm/test/Transforms/DeadStoreElimination/MSSA/pr47285-not-overwritten-on-all-exit-paths.ll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,15 @@ define void @test(i1 %c.0, i1 %c.2, i1 %c.3, i1 %c.4, i1 %c.5, i1 %c.6) {
2525
; CHECK-NEXT: store i32 99, i32* @b, align 4
2626
; CHECK-NEXT: br i1 [[C_3:%.*]], label [[BB_5]], label [[BB_2]]
2727
; CHECK: bb.6:
28+
; CHECK-NEXT: store i32 91, i32* @b, align 4
2829
; CHECK-NEXT: br i1 [[C_5:%.*]], label [[SPLIT_CRIT_EDGE_2:%.*]], label [[BB_2]]
2930
; CHECK: split_crit_edge.2:
3031
; CHECK-NEXT: store i32 27, i32* @b, align 4
3132
; CHECK-NEXT: br label [[EXIT:%.*]]
3233
; CHECK: bb.7:
3334
; CHECK-NEXT: br i1 [[C_4]], label [[INTERESTING:%.*]], label [[BB_8:%.*]]
3435
; CHECK: interesting:
36+
; CHECK-NEXT: store i32 9, i32* @b, align 4
3537
; CHECK-NEXT: br i1 [[C_6:%.*]], label [[KILLER:%.*]], label [[BB_2]]
3638
; CHECK: killer:
3739
; CHECK-NEXT: store i32 23, i32* @b, align 4

0 commit comments

Comments
 (0)