Skip to content

Add simplifier rules helpful for specialization#5836

Merged
dsharletg merged 4 commits intomasterfrom
dsharletg/simplify-specialize
Mar 29, 2021
Merged

Add simplifier rules helpful for specialization#5836
dsharletg merged 4 commits intomasterfrom
dsharletg/simplify-specialize

Conversation

@dsharletg
Copy link
Contributor

This PR makes it easier to simplify the expressions resulting from bounds inference on funcs with specializations.

@dsharletg dsharletg requested a review from abadams March 23, 2021 03:55
rewrite(max(x, max(min(x, y), z)), max(x, z)) ||
rewrite(max(x, max(min(y, x), z)), max(x, z)) ||

rewrite(max(select(x, y, z), z), select(x, max(y, z), z)) ||
Copy link
Member

Choose a reason for hiding this comment

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

@jn80842 I believe this rule is OK because we prefer stronger IR nodes at the root of the true, all else equal. Is that right?

Copy link
Member

Choose a reason for hiding this comment

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

Ok, according to Julie this rule is actually not OK because we prefer weaker nodes at the root, so this may fight with another rule that moves a max inside a select for some reason.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, I'm going to have to look at this, because I did check that these rules are needed, and they really are. I guess I'll have to try to find a more specific rule.

@abadams
Copy link
Member

abadams commented Mar 23, 2021

The rules all formally verify, but I'd like @jn80842 to double-check the one max/select distribution rule that seems barely-ordered to me.

@steven-johnson
Copy link
Contributor

The OSX failure is unrelated (will be fixed by #5841), should be good to land

@abadams
Copy link
Member

abadams commented Mar 26, 2021

The new rules all formally verify

@dsharletg dsharletg merged commit e8085bd into master Mar 29, 2021
@dsharletg dsharletg deleted the dsharletg/simplify-specialize branch March 29, 2021 17:09
gasparitiago pushed a commit to gasparitiago/Halide that referenced this pull request Mar 30, 2021
* Add simplifier rules helpful for specialization.

* clang-format

* Revert sketchy select simplification.

* Add different rules.
@alexreinking alexreinking added this to the v12.0.0 milestone May 19, 2021
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.

4 participants