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] Added simplification rule for multiple equality compares #15628

Conversation

Lunderberg
Copy link
Contributor

The expression (x==y) && (x==z) requires that y==z. When y and z are constants, this can allow better constant folding by rewriting (x==c1) && (x==c2) into (x==c1) && (c1==c2).

This commit adds the above rewrite, and the corresponding rewrite of the negative expression. This was initially part of #15627, but does not depend on Relax features, and is split out in order to upstream into TVM main.

The expression `(x==y) && (x==z)` requires that `y==z`.  When `y` and
`z` are constants, this can allow better constant folding by
rewriting `(x==c1) && (x==c2)` into `(x==c1) && (c1==c2)`.

This commit adds the above rewrite, and the corresponding rewrite of
the negative expression.
@tvm-bot
Copy link
Collaborator

tvm-bot commented Aug 27, 2023

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

Copy link
Member

@junrushao junrushao left a comment

Choose a reason for hiding this comment

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

LGTM!

@junrushao junrushao merged commit 3c6f9c9 into apache:main Aug 28, 2023
6 checks passed
@Lunderberg Lunderberg deleted the arith_simplify_multiple_comparisons_to_constant branch August 29, 2023 02:08
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.

3 participants