Skip to content

Commit a325622

Browse files
authored
[DSE] Allow attribute differences in redundant store elimination (#125190)
When comparing the instructions, enable attribute intersection to allow differences in attributes. Note that we don't actually have to intersect the attributes on the earlier instruction, because we're not RAUWing, so there's no chance that we make any values more poisonous.
1 parent 6dd07b1 commit a325622

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2210,7 +2210,9 @@ struct DSEState {
22102210

22112211
Instruction *UpperInst = UpperDef->getMemoryInst();
22122212
auto IsRedundantStore = [&]() {
2213-
if (DefInst->isIdenticalTo(UpperInst))
2213+
// We don't care about differences in call attributes here.
2214+
if (DefInst->isIdenticalToWhenDefined(UpperInst,
2215+
/*IntersectAttrs=*/true))
22142216
return true;
22152217
if (auto *MemSetI = dyn_cast<MemSetInst>(UpperInst)) {
22162218
if (auto *SI = dyn_cast<StoreInst>(DefInst)) {

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,6 @@ define void @memset_different_attributes_1(i1 %c, ptr %ptr) {
752752
; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr [[PTR:%.*]], i8 0, i64 20, i1 false)
753753
; CHECK-NEXT: br i1 [[C:%.*]], label [[IF:%.*]], label [[END:%.*]]
754754
; CHECK: if:
755-
; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr dereferenceable(20) [[PTR]], i8 0, i64 20, i1 false)
756755
; CHECK-NEXT: br label [[END]]
757756
; CHECK: end:
758757
; CHECK-NEXT: ret void
@@ -773,7 +772,6 @@ define void @memset_different_attributes_2(i1 %c, ptr %ptr) {
773772
; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr dereferenceable(20) [[PTR:%.*]], i8 0, i64 20, i1 false)
774773
; CHECK-NEXT: br i1 [[C:%.*]], label [[IF:%.*]], label [[END:%.*]]
775774
; CHECK: if:
776-
; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr [[PTR]], i8 0, i64 20, i1 false)
777775
; CHECK-NEXT: br label [[END]]
778776
; CHECK: end:
779777
; CHECK-NEXT: ret void

0 commit comments

Comments
 (0)