-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[LICM] Simplify isLoadInvariantInLoop given opaque pointers #65597
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bjope
force-pushed
the
opaque_licm
branch
2 times, most recently
from
September 8, 2023 16:14
a798154
to
82eba00
Compare
nikic
approved these changes
Sep 14, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Since we no longer support typed pointers in LLVM IR, the PtrASXTy in isLoadInvariantInLoop was set to be equal to Addr->getType() (an opaque ptr in the same address space). That made the loop looking through bitcasts redundant.
@llvm/pr-subscribers-llvm-transforms ChangesSince we no longer support typed pointers in LLVM IR, the PtrASXTy in isLoadInvariantInLoop was set to be equal to Addr->getType() (an opaque ptr in the same address space). That made the loop looking through bitcasts redundant.-- 1 Files Affected:
diff --git a/llvm/lib/Transforms/Scalar/LICM.cpp b/llvm/lib/Transforms/Scalar/LICM.cpp index d6e77c904f3aa2c..4cb70cbdf093b36 100644 --- a/llvm/lib/Transforms/Scalar/LICM.cpp +++ b/llvm/lib/Transforms/Scalar/LICM.cpp @@ -1039,7 +1039,7 @@ bool llvm::hoistRegion(DomTreeNode *N, AAResults *AA, LoopInfo *LI, // invariant.start has no uses. static bool isLoadInvariantInLoop(LoadInst *LI, DominatorTree *DT, Loop *CurLoop) { - Value *Addr = LI->getOperand(0); + Value *Addr = LI->getPointerOperand(); const DataLayout &DL = LI->getModule()->getDataLayout(); const TypeSize LocSizeInBits = DL.getTypeSizeInBits(LI->getType()); @@ -1055,21 +1055,6 @@ static bool isLoadInvariantInLoop(LoadInst *LI, DominatorTree *DT, if (LocSizeInBits.isScalable()) return false; - // if the type is ptr addrspace(x), we know this is the type of - // llvm.invariant.start operand - auto *PtrASXTy = PointerType::get(LI->getContext(), - LI->getPointerAddressSpace()); - unsigned BitcastsVisited = 0; - // Look through bitcasts until we reach the PtrASXTy type (this is - // invariant.start operand type). - // FIXME: We shouldn't really find such bitcasts with opaque pointers. - while (Addr->getType() != PtrASXTy) { - auto *BC = dyn_cast<BitCastInst>(Addr); - // Avoid traversing high number of bitcast uses. - if (++BitcastsVisited > MaxNumUsesTraversed || !BC) - return false; - Addr = BC->getOperand(0); - } // If we've ended up at a global/constant, bail. We shouldn't be looking at // uselists for non-local Values in a loop pass. if (isa<Constant>(Addr)) |
kstoimenov
pushed a commit
to kstoimenov/llvm-project
that referenced
this pull request
Sep 14, 2023
Since we no longer support typed pointers in LLVM IR, the PtrASXTy in isLoadInvariantInLoop was set to be equal to Addr->getType() (an opaque ptr in the same address space). That made the loop looking through bitcasts redundant.
This was referenced Sep 14, 2023
ZijunZhaoCCK
pushed a commit
to ZijunZhaoCCK/llvm-project
that referenced
this pull request
Sep 19, 2023
Since we no longer support typed pointers in LLVM IR, the PtrASXTy in isLoadInvariantInLoop was set to be equal to Addr->getType() (an opaque ptr in the same address space). That made the loop looking through bitcasts redundant.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Since we no longer support typed pointers in LLVM IR, the PtrASXTy
in isLoadInvariantInLoop was set to be equal to Addr->getType() (an
opaque ptr in the same address space). That made the loop looking
through bitcasts redundant.