[code-reflection] RFR: Partial evaluator transform
Paul Sandoz
psandoz at openjdk.org
Fri Jun 6 22:58:27 UTC 2025
This test contains an experimental partial evaluator transformer, which takes as input a model and a predicate function that can identify if an operation's result is to be considered as constant, evaluates the constant operations, returns output model containing the evaluated results.
The transformer processes the model by traversing blocks and operations, operations in sequence and blocks in reserve post order. If an operation result is constant, or the operation uses operands that are all constant and therefore its result is also constant, then the operation is evaluated (interpreted) and is replaced with a constant operation whose constant value is the result of the evaluation. Otherwise, the operation is copied.
For forward control flow constant branches are replaced with direct branches, and constant arguments replace associated block parameters.
For loops we peel loop iterations until the iteration is not constant or the loop ends. A constant loop iteration is one whose arguments input to the loop header are constant and there is a constant branch to the loop header. Care needs to be taken when branching back to the loop header. In such cases associated state needs to be reset to peel the next iteration and determine if peeling should then continue. Supporting loops require that they are identified (the loop header, loop latches, loop body, and loop exits), including loops with multiple ways break out and continue.
-------------
Commit messages:
- Support multiple loop latches
- Refine loop analysis.
- Analyze loops when transforming.
- Fix typo.
- Refinements.
- Merge branch 'code-reflection' into partial-eval-transform
- Partial evaluator transform.
Changes: https://git.openjdk.org/babylon/pull/431/files
Webrev: https://webrevs.openjdk.org/?repo=babylon&pr=431&range=00
Stats: 1618 lines in 7 files changed: 1613 ins; 4 del; 1 mod
Patch: https://git.openjdk.org/babylon/pull/431.diff
Fetch: git fetch https://git.openjdk.org/babylon.git pull/431/head:pull/431
PR: https://git.openjdk.org/babylon/pull/431
More information about the babylon-dev
mailing list