Skip to content

Fix incorrect optimization in i64.mul_wide_s translation #1545

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

Merged
merged 1 commit into from
Jun 21, 2025

Conversation

Robbepop
Copy link
Member

@Robbepop Robbepop commented Jun 21, 2025

Closes #1544 .

cc @saulecabrera

Minified example that caused the bug:

(module
  (func (export "run") (param i64) (result i64 i64)
    (i64.mul_wide_s
      (i64.add
        (local.get 0)
        (i64.const -3)
      )
      (i64.const 1)
    )
  )
)

Summary: The Wasmi translator incorrectly applied an optimization for i64.mul_wide_s when one of its operands was i64.const 1 and the other operand was not known to never be negative. In cases where the other operand was negative the result after the optimization was incorrect.

Copy link

codecov bot commented Jun 21, 2025

Codecov Report

Attention: Patch coverage is 33.33333% with 4 lines in your changes missing coverage. Please review.

Project coverage is 72.19%. Comparing base (1a43c8e) to head (45ee5ef).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
crates/wasmi/src/engine/translator/func/mod.rs 0.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1545      +/-   ##
==========================================
+ Coverage   72.17%   72.19%   +0.01%     
==========================================
  Files         179      179              
  Lines       16401    16401              
==========================================
+ Hits        11838    11840       +2     
+ Misses       4563     4561       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Robbepop Robbepop merged commit 51b1ce6 into main Jun 21, 2025
18 of 19 checks passed
@Robbepop Robbepop deleted the rf-fix-i64_mul_wide_s-translation-bug branch June 21, 2025 11: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.

Inconsistent results for Wasm wide-arithmetic proposal operation
1 participant