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

Rework the simplifier to use ConstantInterval for bounds #8222

Merged
merged 21 commits into from
Jun 2, 2024

Conversation

abadams
Copy link
Member

@abadams abadams commented May 15, 2024

Now that ConstantInterval is more powerful, this PR reworks the simplifier to use it for bounds information. This is not quite just a refactor PR, because it also tracks bounds for many more types, resulting in better simplification of e.g. fixed-point expressions.

I also moved the simplify fuzzer back to being a correctness test (see #8171)

Also includes bug-fixes #8220 and #8221, because those would otherwise break this PR. There are no files in common, so if you want to review before those are merged, just ignore the associativity and modulus remainder changes.

abadams added 16 commits May 14, 2024 15:42
The associative ops table defined saturating add as
saturating_narrow(widen(x + y)), instead of saturating_narrow(widen(x) +
y)
A default-constructed ModulusRemainder means no information, which is
what we want here. ModulusRemainder{0, 1} means the constant one!
and track the bounds through more types
…erflow' into abadams/constant_interval_simplifier
…iativity' into abadams/constant_interval_simplifier
Otherwise it causes a race condition in any parallel tests
The contradiction was arising from:

if (extent > 0) {
...
} else {
  for (x = 0; x < extent; x++) {
In here we can assume extent > 0, but we also know from the if
statement that extent <= 0
  }
}
src/Simplify_Div.cpp Outdated Show resolved Hide resolved
src/Simplify_Div.cpp Outdated Show resolved Hide resolved
src/Simplify_Max.cpp Outdated Show resolved Hide resolved
src/Simplify_Select.cpp Outdated Show resolved Hide resolved
src/Simplify_Stmts.cpp Outdated Show resolved Hide resolved
Copy link
Member

@rootjalex rootjalex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm with nits

@abadams
Copy link
Member Author

abadams commented Jun 2, 2024

Failures unrelated. Merging.

@abadams abadams merged commit a9b8fbf into main Jun 2, 2024
3 checks passed
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