Skip to content

[mlir][Sol] Widen int operand of bytes_cast to match destination#131

Merged
abinavpp merged 1 commit into
mainfrom
app-bytes-cast-int-widen
May 22, 2026
Merged

[mlir][Sol] Widen int operand of bytes_cast to match destination#131
abinavpp merged 1 commit into
mainfrom
app-bytes-cast-int-widen

Conversation

@abinavpp

Copy link
Copy Markdown
Contributor

Solidity-only; no companion mlir PR.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes Solidity-to-MLIR codegen for integer→bytesN casts by ensuring the integer operand is first cast to the exact bit-width required by sol.bytes_cast, and adds regression tests to lock in the behavior.

Changes:

  • Adjust SolidityToMLIRPass::genCast to cast integer operands to the destination byte-width before emitting sol.bytes_cast.
  • Add new mlirCodegen and mlirCodegen/EVM lit tests covering bytes32(uint8)-style widening behavior.
  • Update test/mlirSemtestFailures.txt to remove entries that are no longer expected to fail.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
test/mlirSemtestFailures.txt Removes no-longer-failing semantic tests from the expected-fail list.
test/lit/mlirCodegen/EVM/bytes-cast-int-widen.sol Adds an EVM-lowering regression test for integer widening prior to bytes_cast.
test/lit/mlirCodegen/bytes-cast-int-widen.sol Adds an init-IR regression test for integer widening prior to bytes_cast.
libsolidity/codegen/mlir/SolidityToMLIR.cpp Inserts an integer cast to match bytes_cast’s required operand width for byte/fixedbytes<N> destinations.

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

Comment thread libsolidity/codegen/mlir/SolidityToMLIR.cpp Outdated
@abinavpp abinavpp force-pushed the app-bytes-cast-int-widen branch from 90fd667 to 2cdfce9 Compare May 15, 2026 10:25

@PavelKopyl PavelKopyl 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.

LGTM.

@abinavpp abinavpp force-pushed the app-modifier-on-constructor-kind branch from 7f03134 to 480103b Compare May 18, 2026 23:53
@abinavpp abinavpp force-pushed the app-bytes-cast-int-widen branch from 2cdfce9 to 8dbebdf Compare May 18, 2026 23:53
@abinavpp abinavpp force-pushed the app-modifier-on-constructor-kind branch from 480103b to e16453d Compare May 22, 2026 11:08
@abinavpp abinavpp force-pushed the app-bytes-cast-int-widen branch from 8dbebdf to 7493966 Compare May 22, 2026 11:08
@abinavpp abinavpp force-pushed the app-modifier-on-constructor-kind branch from e16453d to fc2ff64 Compare May 22, 2026 11:57
Base automatically changed from app-modifier-on-constructor-kind to main May 22, 2026 11:57
Required by sol.bytes_cast verifier (bitwidth(int) == 8 * size(bytes));
e.g. bytes32(0) where 0 is typed ui8.
@abinavpp abinavpp force-pushed the app-bytes-cast-int-widen branch from 7493966 to c45bf56 Compare May 22, 2026 11:58
@abinavpp abinavpp merged commit 4a37478 into main May 22, 2026
1 check passed
@abinavpp abinavpp deleted the app-bytes-cast-int-widen branch May 22, 2026 11:59
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