Skip to content

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
@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