Skip to content

[mlir] Fix CMulOp lowering#83

Merged
PavelKopyl merged 1 commit intomainfrom
kpv-fix-cmul
Mar 13, 2026
Merged

[mlir] Fix CMulOp lowering#83
PavelKopyl merged 1 commit intomainfrom
kpv-fix-cmul

Conversation

@PavelKopyl
Copy link
Copy Markdown
Contributor

@PavelKopyl PavelKopyl commented Mar 12, 2026

Avoid undefined behavior when checking for multiplication overflow.

solx-llvm

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates MLIR/EVM codegen test expectations to match the new CMulOp overflow-check lowering that avoids division-by-zero/UB, and adds a semantic regression case to ensure ofm(int8) behaves correctly for input 0.

Changes:

  • Update EVM MLIR FileCheck expectations to use a guarded divisor (arith.select) before arith.divui/divsi in multiplication overflow checks.
  • Refresh variable numbering / block contents in generated MLIR checks (panic/revert sequences, stores) to match updated lowering output.
  • Add a semantic test case covering ofm(int8): 0 -> 0.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated no comments.

File Description
test/lit/mlirCodegen/EVM/ctor.sol Updates FileCheck patterns for constructor codegen to reflect safe mul-overflow checks (guarded division).
test/lit/mlirCodegen/EVM/arith.sol Updates FileCheck patterns for arithmetic codegen; introduces guarded division in mul-overflow checks and adjusts expected IR accordingly.
test/libsolidity/semanticTests/mlir/arith.sol Adds a semantic regression expectation for ofm(int8) with input 0.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Copy link
Copy Markdown
Contributor

@abinavpp abinavpp left a comment

Choose a reason for hiding this comment

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

Thank you!

@PavelKopyl PavelKopyl merged commit ed193f6 into main Mar 13, 2026
2 checks passed
@PavelKopyl PavelKopyl deleted the kpv-fix-cmul branch March 13, 2026 12:15
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.

3 participants