Skip to content

[opt] Add simplification for division by a bounded set of constants.#4101

Draft
copybara-service[bot] wants to merge 1 commit intomainfrom
test_896714610
Draft

[opt] Add simplification for division by a bounded set of constants.#4101
copybara-service[bot] wants to merge 1 commit intomainfrom
test_896714610

Conversation

@copybara-service
Copy link
Copy Markdown

[opt] Add simplification for division by a bounded set of constants.

When a division's divisor is known to take values only from a small set of constants (or even a large set, if almost all of them are powers of two), we replace the expensive variable-divisor division with a select tree over constant divisions. This avoids expensive hardware dividers by allowing subsequent passes to reduce the constant divisions into multiplications or shifts.

This provides a significant area and/or latency win for cases where the set of possible divisors is small - and gives us more opportunity to let users express division naturally without getting a full hardware divider.

When a division's divisor is known to take values only from a small set of constants (or even a large set, if almost all of them are powers of two), we replace the expensive variable-divisor division with a select tree over constant divisions. This avoids expensive hardware dividers by allowing subsequent passes to reduce the constant divisions into multiplications or shifts.

This provides a significant area and/or latency win for cases where the set of possible divisors is small - and gives us more opportunity to let users express division naturally without getting a full hardware divider.

PiperOrigin-RevId: 896714610
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.

1 participant