Skip to content
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

Simplification pass #256

Open
wants to merge 120 commits into
base: main
Choose a base branch
from
Open

Simplification pass #256

wants to merge 120 commits into from

Conversation

ailrst
Copy link
Contributor

@ailrst ailrst commented Oct 9, 2024

Adds the flag --simplify (which implies --parameter-form) which, after running analysis performs partial evaluation and simplification of the IR.

This usually removes the flag registers and pushes the comparisons into the assume statements where they are used, folds constants through and does some canonicalisation and term simplification.

It sits on top of the interpreter #241 for partial evaluation, and includes improvements to the parameter form which I will copy into that PR #255. When #243 is merged we should use the interpreter to validate the transform using the memory state hash the csmith examples produce. Currently this is just validated against the system tests, all of which pass with the transform applied.

this implements:

  • lift registers to locals and pass everything via procedure parameters (this required adding parameters to the IR)
  • a dynamic single assignment transform via variable renaming, adds an index field to local variables for this purpose so we can easily rename them without
  • constant + copy propagation over the IR
  • multiple term-rewriting based simplification passes
  • a pass to convert 64 bit locals where only the low n bits are accessed to variables of n bits

The simplification/partial eval/copyprop rewrites are applied repeatedly with a fixed number of iterations.

For an example of what simplifications this produces: https://gist.github.com/ailrst/1b29e85a6ad891810dcc83801b1e2c6a

@ailrst ailrst changed the base branch from interpreter to main November 28, 2024 01:16
@ailrst ailrst mentioned this pull request Nov 28, 2024
@ailrst ailrst force-pushed the simplification-pass branch from b81e661 to 21efc16 Compare December 5, 2024 00:31
@ailrst ailrst force-pushed the simplification-pass branch from ba1d53d to d5a744b Compare January 6, 2025 03:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants