Skip to content

[CombToSynth] Add a lowering for mod/div where rhs is constant#10584

Open
okekayode wants to merge 1 commit into
llvm:mainfrom
okekayode:dev/mod-div-lowering
Open

[CombToSynth] Add a lowering for mod/div where rhs is constant#10584
okekayode wants to merge 1 commit into
llvm:mainfrom
okekayode:dev/mod-div-lowering

Conversation

@okekayode
Copy link
Copy Markdown
Contributor

@okekayode okekayode commented Jun 4, 2026

Concerns #10569

In this PR we add lowerings for comb.divu, comb.modu, comb.divs, and comb.mods in the case that the RHS is a constant value. For the division operators , we utilise UnsignedDivisionByConstantInfo and SignedDivisionByConstantInfo to replace the operation with magic multiplication, shifts, and adds. For modulo, we reuse the division lowering via x % k = x - ((x / k) * k) = remainder

Assisted-by: claude: sonnet 4.6

@circt-bot
Copy link
Copy Markdown

circt-bot Bot commented Jun 4, 2026

Results of circt-tests run for 759682f compared to results for 7aa41cc: no change to test results.

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