-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[LAA] Improve code in findForkedSCEVs (NFC) #140384
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
Merged
Merged
Conversation
This file contains hidden or 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
@llvm/pr-subscribers-llvm-analysis Author: Ramkumar Ramachandra (artagnon) ChangesFull diff: https://github.com/llvm/llvm-project/pull/140384.diff 1 Files Affected:
diff --git a/llvm/lib/Analysis/LoopAccessAnalysis.cpp b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
index ab407e945bc53..58083cb06f5f6 100644
--- a/llvm/lib/Analysis/LoopAccessAnalysis.cpp
+++ b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
@@ -999,23 +999,16 @@ static void findForkedSCEVs(
break;
}
- // Find the pointer type we need to extend to.
- Type *IntPtrTy = SE->getEffectiveSCEVType(
- SE->getSCEV(GEP->getPointerOperand())->getType());
-
- // Find the size of the type being pointed to. We only have a single
- // index term (guarded above) so we don't need to index into arrays or
- // structures, just get the size of the scalar value.
- const SCEV *Size = SE->getSizeOfExpr(IntPtrTy, SourceTy);
-
// Scale up the offsets by the size of the type, then add to the bases.
+ const SCEV *Offset0 = get<0>(OffsetScevs[0]);
+ const SCEV *Offset1 = get<0>(OffsetScevs[1]);
+ const SCEV *Scaled0 = SE->getMulExpr(
+ SE->getSizeOfExpr(Offset0->getType(), SourceTy), Offset0);
const SCEV *Scaled1 = SE->getMulExpr(
- Size, SE->getTruncateOrSignExtend(get<0>(OffsetScevs[0]), IntPtrTy));
- const SCEV *Scaled2 = SE->getMulExpr(
- Size, SE->getTruncateOrSignExtend(get<0>(OffsetScevs[1]), IntPtrTy));
- ScevList.emplace_back(SE->getAddExpr(get<0>(BaseScevs[0]), Scaled1),
+ SE->getSizeOfExpr(Offset1->getType(), SourceTy), Offset1);
+ ScevList.emplace_back(SE->getAddExpr(get<0>(BaseScevs[0]), Scaled0),
NeedsFreeze);
- ScevList.emplace_back(SE->getAddExpr(get<0>(BaseScevs[1]), Scaled2),
+ ScevList.emplace_back(SE->getAddExpr(get<0>(BaseScevs[1]), Scaled1),
NeedsFreeze);
break;
}
|
fhahn
reviewed
May 18, 2025
fhahn
reviewed
May 19, 2025
0fc49fc
to
74b711b
Compare
Gentle ping. |
74b711b
to
4a093b1
Compare
fhahn
approved these changes
Jun 3, 2025
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, thanks
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.
No description provided.