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

add rewrites for hoisting constants from ite expressions #7462

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

NikolajBjorner
Copy link
Contributor

@NikolajBjorner NikolajBjorner commented Nov 22, 2024

This pull request

  • removes pushing arithmetic operations over ite operations.
  • adds hoisting of constants from ite expressions using rewrites
    • ite c v1 v2 -> g * ite c (v1/g) (v2/g) where g is gcd(v1, v2) != 1
    • ite c v1 v2 -> v1 + ite c 0 (v2 - v1)
    • ite c (v1 + t) v2 -> v1 + ite c t (v2 - v1)
    • ite c v1 (v2 + t) -> v2 + ite c (v1 - v2) t
    • ite c (v1 * t) 0 -> v1 * ite c t 0
    • ite c (v1 * t) v2 -> v1 * ite c t (v2/ v1) if v1 divides v2

return BR_DONE;
}
if (is_num1 && is_num2 && is_int && gcd(v1, v2) != 1) {
auto g = gcd(v1, v2);
Copy link
Contributor

Choose a reason for hiding this comment

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

gcd computation is called twice.

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