[pull] master from phate:master#623
Merged
pull[bot] merged 1 commit intoEECS-NTNU:masterfrom Jan 26, 2026
Merged
Conversation
This PR extends the existing scalar evolution analysis implementation by adding support for handling subtraction and multiplication operations. Previously, statements that included these operations were treated as unknown. More specifically, it adds cases for treating subtraction and multiplication operations. For multiplication, (two) new `SCEV` types are added, a `SCEVMulExpr` and a `SCEVNAryMulExpr`, mirroring the `SCEVAddExpr` and `SCEVNAryAddExpr` for addition operations, a new method for folding multiplication operations, `ApplyMultFolding()`, is also added. Subtraction however, does not have its own SCEV type(s), but is rather treated as an addition with the right hand-side of the expression being negated, and so it does not require as much logic to support. A new method called `GetNegativeSCEV()` is added for this purpose. In order to support different operations, we also need to keep track of which operation with which a variable depends on another (or itself). As a result, the dependency logic (necessary for invalidating certain cases and topological sorting) has been extended to include the operation as well as the number of times a variable depends on another. Currently, the implementation treats variables that have direct dependencies with multiplication (i.e. a = a * 2) as invalid, whilst other cases of multiplication that don't result in geometric sequences are OK, (e.g. a = a + b * 2). This is mainly because these are not able to be modeled as affine recurrences and because the main focus of LLVM's SCEV is linear and polynomial sequences, and these are the ones that are most relevant for optimizations like loop strength reduction and induction variable substitution.
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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.4)
Can you help keep this open source service alive? 💖 Please sponsor : )