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

[Arith][TIR] Check for constant offsets of known literal constraints #13023

Merged

Conversation

Lunderberg
Copy link
Contributor

Previously, the checks for a literal constraint would find exact matches for an inequality, but any alterations to the conditional would break this exact matching. This commit introduces checks for constant offsets relative to a known value. These checks are not always expressible using the existing ConstIntSetAnalyzer, which represents allowed values using a single contiguous region. (e.g. i!=5 is not representable, because it requires a region for i<5 and another for i>5.)

This implementation reuses the internal representation for inequalities introduced in #12863, along with much of its implementation. However, the indirect comparisons (e.g. using a < b and b < c to prove that a < c) introduced in that PR still require an explicit flag to be used.

@Lunderberg
Copy link
Contributor Author

This is part of a series of improved simplifications, as part of #12261.

@Lunderberg
Copy link
Contributor Author

Rebased onto main to resolve merge conflict.

@tvm-bot
Copy link
Collaborator

tvm-bot commented Oct 18, 2022

Thanks for contributing to TVM! Please refer to the contributing guidelines https://tvm.apache.org/docs/contribute/ for useful information and tips. Please request code reviews from Reviewers by @-ing them in a comment.

Generated by tvm-bot

@areusch areusch added needs-triage PRs or issues that need to be investigated by maintainers to find the right assignees to address it and removed needs-triage PRs or issues that need to be investigated by maintainers to find the right assignees to address it labels Oct 19, 2022
Copy link
Contributor

@jwfromm jwfromm left a comment

Choose a reason for hiding this comment

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

Very cool! LGTM.

Previously, the checks for a literal constraint would find exact
matches for an inequality, but any alterations to the conditional
would break this exact matching.  This commit introduces checks for
constant offsets relative to a known value.  These checks are not
always expressible using the existing `ConstIntSetAnalyzer`, which
represents allowed values using a single contiguous
region.  (e.g. `i!=5` is not representable, because it requires a
region for `i<5` and another for `i>5`.)

This implementation reuses the internal representation for
inequalities introduced in apache#12863,
along with much of its implementation.  However, the indirect
comparisons (e.g. using `a < b` and `b < c` to prove that `a < c`)
introduced in that PR still require an explicit flag to be used.
@Lunderberg Lunderberg force-pushed the use_direct_comparisons_to_prove_statements branch from 15c1b1c to bb2f4ed Compare October 28, 2022 18:39
@Lunderberg
Copy link
Contributor Author

Thank you! (Rebasing onto main to resolve conflicts.)

@csullivan
Copy link
Contributor

@tvm-bot rerun

@csullivan csullivan merged commit 25a0d47 into apache:main Oct 29, 2022
@Lunderberg Lunderberg deleted the use_direct_comparisons_to_prove_statements branch October 31, 2022 13:21
xinetzone pushed a commit to daobook/tvm that referenced this pull request Nov 10, 2022
…pache#13023)

Previously, the checks for a literal constraint would find exact
matches for an inequality, but any alterations to the conditional
would break this exact matching.  This commit introduces checks for
constant offsets relative to a known value.  These checks are not
always expressible using the existing `ConstIntSetAnalyzer`, which
represents allowed values using a single contiguous
region.  (e.g. `i!=5` is not representable, because it requires a
region for `i<5` and another for `i>5`.)

This implementation reuses the internal representation for
inequalities introduced in apache#12863,
along with much of its implementation.  However, the indirect
comparisons (e.g. using `a < b` and `b < c` to prove that `a < c`)
introduced in that PR still require an explicit flag to be used.
xinetzone pushed a commit to daobook/tvm that referenced this pull request Nov 25, 2022
…pache#13023)

Previously, the checks for a literal constraint would find exact
matches for an inequality, but any alterations to the conditional
would break this exact matching.  This commit introduces checks for
constant offsets relative to a known value.  These checks are not
always expressible using the existing `ConstIntSetAnalyzer`, which
represents allowed values using a single contiguous
region.  (e.g. `i!=5` is not representable, because it requires a
region for `i<5` and another for `i>5`.)

This implementation reuses the internal representation for
inequalities introduced in apache#12863,
along with much of its implementation.  However, the indirect
comparisons (e.g. using `a < b` and `b < c` to prove that `a < c`)
introduced in that PR still require an explicit flag to be used.
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.

5 participants