Skip to content

Commit eb91d91

Browse files
committed
[DSE] Fix typo in recent commit
This fixes a typo in 81d69e1. Of course we should only skip the particular store if it isn't removable, not bail out of the whole loop. Add a test to cover this case.
1 parent 90095a0 commit eb91d91

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1873,7 +1873,7 @@ struct DSEState {
18731873
Instruction *DefInst = Def->getMemoryInst();
18741874
auto MaybeDefLoc = getLocForWrite(DefInst);
18751875
if (!MaybeDefLoc || !isRemovable(DefInst))
1876-
return false;
1876+
continue;
18771877

18781878
MemoryDef *UpperDef;
18791879
// To conserve compile-time, we avoid walking to the next clobbering def.

llvm/test/Transforms/DeadStoreElimination/stores-of-existing-values.ll

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -650,3 +650,27 @@ define i8 @memset_optimized_access(i8* noalias %dst, i8* noalias %src) {
650650
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* %dst, i8* %src, i64 16, i1 false)
651651
ret i8 %l
652652
}
653+
654+
; The @use() call is a later non-removable store, but should not affect the
655+
; removal of the store in the if block.
656+
define void @later_non_removable_store(i1 %c, i8* %p) {
657+
; CHECK-LABEL: @later_non_removable_store(
658+
; CHECK-NEXT: store i8 1, i8* [[P:%.*]], align 1
659+
; CHECK-NEXT: br i1 [[C:%.*]], label [[IF:%.*]], label [[EXIT:%.*]]
660+
; CHECK: if:
661+
; CHECK-NEXT: br label [[EXIT]]
662+
; CHECK: exit:
663+
; CHECK-NEXT: call void @use(i8* [[P]]) #[[ATTR6:[0-9]+]]
664+
; CHECK-NEXT: ret void
665+
;
666+
store i8 1, i8* %p
667+
br i1 %c, label %if, label %exit
668+
669+
if:
670+
store i8 1, i8* %p
671+
br label %exit
672+
673+
exit:
674+
call void @use(i8* %p) argmemonly
675+
ret void
676+
}

0 commit comments

Comments
 (0)