-
Notifications
You must be signed in to change notification settings - Fork 18
ScalarEvolution: Recurrences for GEP operations #1525
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
andreaslhjulstad
merged 8 commits into
phate:master
from
andreaslhjulstad:get-element-ptr
Feb 10, 2026
Merged
ScalarEvolution: Recurrences for GEP operations #1525
andreaslhjulstad
merged 8 commits into
phate:master
from
andreaslhjulstad:get-element-ptr
Feb 10, 2026
+571
−186
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
This approach seems like the best choice moving forward, and is necessary for supporting getelementptr instructions. Also updates the tests accordingly. In particular, we no longer care about the size of the resulting chrec map in the tests, as a lot more outputs now have computed chrecs than only the loop variables. We still check that the loop variables are in the map in the tests, so no behavior has changed there.
phate
reviewed
Feb 9, 2026
Worked fine locally, but crashed when building on GitHub
phate
reviewed
Feb 10, 2026
Owner
phate
left a comment
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.
I have some more comments to the map accessor methods.
phate
approved these changes
Feb 10, 2026
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.
This PR extends the ScalarEvolution implementation by adding support for computing recurrences for
GetElementPtroperations. It does this by adding a few new cases to theGetOrCreateSCEVForOutput()method, particularly forGetElementPtr,Load,IOBarrierandSExtoperations. The SCEV for the GetElementPtr operation is computed recursively to support an arbitrary number of indexes, and supports both array and struct GEPs. This PR also adds two simple tests for the two types of GEPs.Since the value of a GEP is not directly tied to the update of an induction variable (passes through a load from memory), some changes were needed in the way recurrences are computed. Particularly, we now compute recurrences for all valid SCEVs as opposed to computing the recurrences for just the loop variables. By valid we mean that the dependencies for the RVSDG output the SCEV corresponds to passes the three requirements. These being:
This change means that we end up with a larger amount of chain recurrences at the end of the analysis, some of which can be seen as "junk" or "noise". For the analysis itself this makes no difference, however for measuring the results, we should probably filter most of these out.