[PATCH] D112315: [DSE] Use optimized access if available for redundant store elimination.
Florian Hahn via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Oct 30 10:25:57 PDT 2021
fhahn updated this revision to Diff 383604.
fhahn added a comment.
Rebase on top of 0a2b052eb0a59e0df3c8227c1f39d9b1017b38a6.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D112315/new/
https://reviews.llvm.org/D112315
Files:
llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
llvm/test/Transforms/DeadStoreElimination/stores-of-existing-values.ll
Index: llvm/test/Transforms/DeadStoreElimination/stores-of-existing-values.ll
===================================================================
--- llvm/test/Transforms/DeadStoreElimination/stores-of-existing-values.ll
+++ llvm/test/Transforms/DeadStoreElimination/stores-of-existing-values.ll
@@ -324,7 +324,6 @@
; CHECK: bb2:
; CHECK-NEXT: ret void
; CHECK: bb3:
-; CHECK-NEXT: store i32 0, i32* [[P]], align 4
; CHECK-NEXT: ret void
;
store i32 0, i32* %P
@@ -416,8 +415,6 @@
; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* [[PTR:%.*]], i8 0, i64 10, i1 false)
; CHECK-NEXT: [[PTR_4:%.*]] = getelementptr i8, i8* [[PTR]], i64 4
; CHECK-NEXT: store i8 8, i8* [[PTR_4]], align 1
-; CHECK-NEXT: [[PTR_5:%.*]] = getelementptr i8, i8* [[PTR]], i64 5
-; CHECK-NEXT: store i8 0, i8* [[PTR_5]], align 1
; CHECK-NEXT: ret void
;
call void @llvm.memset.p0i8.i64(i8* %ptr, i8 0, i64 10, i1 false)
@@ -506,8 +503,8 @@
define void @test14_strcat(i8* noalias %P, i8* noalias %Q) {
; CHECK-LABEL: @test14_strcat(
-; CHECK-NEXT: call i8* @strcat(i8* [[P:%.*]], i8* [[Q:%.*]])
-; CHECK-NEXT: call i8* @strcat(i8* [[P]], i8* [[Q]])
+; CHECK-NEXT: [[CALL1:%.*]] = call i8* @strcat(i8* [[P:%.*]], i8* [[Q:%.*]])
+; CHECK-NEXT: [[CALL2:%.*]] = call i8* @strcat(i8* [[P]], i8* [[Q]])
; CHECK-NEXT: ret void
;
%call1 = call i8* @strcat(i8* %P, i8* %Q)
Index: llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
+++ llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
@@ -1987,7 +1987,11 @@
if (SkipStores.contains(Def) || MSSA.isLiveOnEntryDef(Def) ||
!isRemovable(Def->getMemoryInst()))
continue;
- auto *UpperDef = dyn_cast<MemoryDef>(Def->getDefiningAccess());
+ MemoryDef *UpperDef;
+ if (Def->isOptimized())
+ UpperDef = dyn_cast<MemoryDef>(Def->getOptimized());
+ else
+ UpperDef = dyn_cast<MemoryDef>(Def->getDefiningAccess());
if (!UpperDef || MSSA.isLiveOnEntryDef(UpperDef))
continue;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D112315.383604.patch
Type: text/x-patch
Size: 2161 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211030/2531e8d3/attachment.bin>
More information about the llvm-commits
mailing list