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

[CombToAIG] Add support for div/mod operations #8130

Merged
merged 1 commit into from
Feb 3, 2025

Conversation

uenoku
Copy link
Member

@uenoku uenoku commented Jan 25, 2025

This patch adds support for lowering comb div/mod operations to AIG:

  • Support unsigned div/mod for power-of-2 constant divisors
  • Support for non-power-of-2 divisors by emulating the operation with a mux tree when the number of unknown bits is small (default threshold is 10 bits). This is not ideal and eventually we should lower to a proper div/mod. Practically this lowering pattern covers many cases since users rarely use div/mod because these operations are very expensive (users write their own div/mod in their frontend language).
  • LEC tests are added.

@uenoku uenoku force-pushed the dev/hidetou/aig-divmod branch 2 times, most recently from 88c68a8 to 3b11ca9 Compare January 25, 2025 10:31
@uenoku uenoku force-pushed the dev/hidetou/aig-divmod branch from 3b11ca9 to 46077e1 Compare January 25, 2025 19:15
This patch adds support for lowering comb div/mod operations to AIG:
* Support for power-of-2 constant divisors by converting to shifts
* Support for non-power-of-2 divisors by emulating the operation with a mux tree
  when the number of unknown bits is small (default threshold: 10 bits)
* Support for both signed and unsigned div/mod operations
* Added integration tests to verify correctness
@uenoku uenoku force-pushed the dev/hidetou/aig-divmod branch from 46077e1 to cda5bbd Compare January 25, 2025 19:16
Copy link
Contributor

@fabianschuiki fabianschuiki left a comment

Choose a reason for hiding this comment

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

LGTM! I agree that people will mostly build their own dividers, since there are so many different architectures. In the long run there might be a "simple" long division that AIG could lower to.

@uenoku uenoku merged commit ee62dbc into llvm:main Feb 3, 2025
5 checks passed
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