[PATCH] D79097: [GVN] Improve analysis for missed optimization remark
Henrik G Olsson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 29 09:06:14 PDT 2020
hnrklssn created this revision.
hnrklssn added reviewers: anemet, hfinkel.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.
This change tries to handle multiple dominating users of the pointer operand
by choosing the most immediately dominating one, if possible.
While making this change I also found that the previous implementation
had a missing break statement, making all loads with an odd number of
dominating users emit an OtherAccess value, so that has also been fixed.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D79097
Files:
llvm/lib/Transforms/Scalar/GVN.cpp
Index: llvm/lib/Transforms/Scalar/GVN.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/GVN.cpp
+++ llvm/lib/Transforms/Scalar/GVN.cpp
@@ -861,12 +861,19 @@
for (auto *U : LI->getPointerOperand()->users())
if (U != LI && (isa<LoadInst>(U) || isa<StoreInst>(U)) &&
DT->dominates(cast<Instruction>(U), LI)) {
- // FIXME: for now give up if there are multiple memory accesses that
- // dominate the load. We need further analysis to decide which one is
- // that we're forwarding from.
- if (OtherAccess)
- OtherAccess = nullptr;
- else
+ // Use the most immediately dominating value
+ if (OtherAccess) {
+ if (DT->dominates(cast<Instruction>(OtherAccess),
+ cast<Instruction>(U))) {
+ OtherAccess = U;
+ } else if (!DT->dominates(cast<Instruction>(U),
+ cast<Instruction>(OtherAccess))) {
+ // No strict domination relationship implies partial redundancy
+ // and we don't know which one
+ OtherAccess = nullptr;
+ break;
+ } // else: the current access is more immediate to LI, so keep it
+ } else
OtherAccess = U;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79097.260931.patch
Type: text/x-patch
Size: 1274 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200429/c7ef6ed6/attachment-0001.bin>
More information about the llvm-commits
mailing list