[PATCH] D97155: [MSSA] Extending IsGuaranteedLoopInvariant to support an instruction defined in the entry block
Matteo Favaro via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Feb 21 08:56:58 PST 2021
fvrmatteo created this revision.
fvrmatteo added a reviewer: fhahn.
Herald added subscribers: asbirlea, george.burgess.iv, hiraditya, Prazek.
fvrmatteo requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
As mentioned in D96979 <https://reviews.llvm.org/D96979>, I'm extending the **IsGuaranteedLoopInvariant** check also to the `MemorySSA.cpp` file.
@fhahn For now I didn't unify the function into `MemorySSA.h` because, as you mentioned, it's not directly MSSA related. I'm open to suggestions to find a better place so we can improve the unification process.
I was also wondering if it would make sense to have a utility function called **isEntryBlockInstruction** (part of llvm::Instruction) to avoid the ugly check used in this (and the mentioned) patch.
I didn't provide a test yet, because it's not clear to me how to create one that is showing the improvement in the MemorySSA case.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D97155
Files:
llvm/lib/Analysis/MemorySSA.cpp
Index: llvm/lib/Analysis/MemorySSA.cpp
===================================================================
--- llvm/lib/Analysis/MemorySSA.cpp
+++ llvm/lib/Analysis/MemorySSA.cpp
@@ -2551,6 +2551,11 @@
};
Ptr = Ptr->stripPointerCasts();
+ if (auto *I = dyn_cast<Instruction>(Ptr)) {
+ if (I->getParent() == &I->getFunction()->getEntryBlock()) {
+ return true;
+ }
+ }
if (auto *GEP = dyn_cast<GEPOperator>(Ptr)) {
return IsGuaranteedLoopInvariantBase(GEP->getPointerOperand()) &&
GEP->hasAllConstantIndices();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D97155.325311.patch
Type: text/x-patch
Size: 551 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210221/0fe382ef/attachment.bin>
More information about the llvm-commits
mailing list