Skip to content

[pull] master from phate:master#623

Merged
pull[bot] merged 1 commit intoEECS-NTNU:masterfrom
phate:master
Jan 26, 2026
Merged

[pull] master from phate:master#623
pull[bot] merged 1 commit intoEECS-NTNU:masterfrom
phate:master

Conversation

@pull
Copy link

@pull pull bot commented Jan 26, 2026

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 : )

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.
@pull pull bot locked and limited conversation to collaborators Jan 26, 2026
@pull pull bot added the ⤵️ pull label Jan 26, 2026
@pull pull bot merged commit 560637e into EECS-NTNU:master Jan 26, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant