Skip to content

fix: edge case handling in intrinsic i32::overflowing_mul#1167

Merged
mooori merged 3 commits into
nextfrom
mooori/fix-intrinsic-i32-overflowing-mul
Jun 10, 2026
Merged

fix: edge case handling in intrinsic i32::overflowing_mul#1167
mooori merged 3 commits into
nextfrom
mooori/fix-intrinsic-i32-overflowing-mul

Conversation

@mooori

@mooori mooori commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Stacked on top of #1160 to have intrinsic testing available.

i32::MIN * 0 does not overflow

Closes #1161

Previously: Overflow was reported for i32::MIN * 0, though the result is 0.
Now: Don't report overflow

While working on this I found another issue:

i32::MIN * odd_number equals (true, i32::MIN)

Previously: This would return (true, 0) because of an incorrect assumption:

# 3. For any other value, there is overflow, and the result is zero

Now: Returns (true, i32::MIN), for example

i32::MIN.overflowing_mul(3) // == i32::MIN

@mooori mooori marked this pull request as ready for review June 9, 2026 12:06
@mooori mooori requested review from bitwalker and greenhat June 9, 2026 12:06
@mooori mooori linked an issue Jun 9, 2026 that may be closed by this pull request

@greenhat greenhat left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looking good!

}

#[test]
#[ignore = "https://github.com/0xMiden/compiler/issues/1161"]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Given that checked_mul is just overflowing_mul followed by assertz, the i32_checked_mul test should also work now.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oh yeah, forgot to remove the ignore. Done now.

Base automatically changed from mooori/intrinsic-testing to next June 10, 2026 11:51
@mooori mooori merged commit 9fbc45c into next Jun 10, 2026
18 checks passed
@mooori mooori deleted the mooori/fix-intrinsic-i32-overflowing-mul branch June 10, 2026 14:34
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.

Native/MASM divergence for intrinsic i32::overflowing_mul

2 participants