Skip to content

[Mono][AMD64] Fix code generation for oversized add immediates. - #134933

Merged
lateralusX merged 1 commit into
dotnet:mainfrom
lateralusX:lateralusX/fix-amd64-large-add-imm
Oct 1, 2026
Merged

lateralusX merged 1 commit into
dotnet:mainfrom
lateralusX:lateralusX/fix-amd64-large-add-imm

Conversation

@lateralusX

Copy link
Copy Markdown
Member

Fix Mono AMD64 code generation for address additions whose constants exceed the signed 32-bit immediate range.

Value-type load/store decomposition can introduce these additions when accessing array elements at large constant indices. Previously, they could:

  • Trigger an assertion during AOT compilation when emitting ADD.
  • Be rewritten by the JIT peephole pass into LEA with a truncated displacement.

Materialize oversized constants with OP_I8CONST and use register-register OP_LADD during lowering, before peephole optimization and register allocation. Additions with encodable immediates remain unchanged.

The existing Runtime_133785 test exposed this pre-existing defect. No tests are disabled.

Fixes #134301
Fixes #134651
Fixes #134692
Fixes #134832

Value-type load/store decomposition can introduce address additions whose constants exceed the signed 32-bit immediate range. Materialize these constants with OP_I8CONST and use OP_LADD before peephole optimization and register allocation.

This avoids the MiniFullAOT emitter assertion and prevents the JIT peephole pass from encoding a truncated LEA displacement. Encodable add immediates remain unchanged.

Fixes dotnet#134301

Validated Linux x64 Release Mono, full-AOT compilation of Regression_ro_2 and dependencies, and Runtime_133785 under default JIT, JIT without peephole optimization, and full-AOT execution.
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 4 pipeline(s).
12 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @steveisok, @vitek-karas
See info in area-owners.md if you want to be subscribed.

@lateralusX

Copy link
Copy Markdown
Member Author

/ba-g The Mono LLVM full-AOT crash in OffsetLimit.DecGtArrayLengthPlusMaxValue matches #134014; its existing quarantine covers llvmaot but misses llvmfullaot. The WebSocket failure is already matched against #134815. Both are pre-existing failures unrelated to this PR.

@lateralusX
lateralusX merged commit eb086e5 into dotnet:main Oct 1, 2026
81 of 85 checks passed
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Oct 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment