[mlir] Add tests for the bytesN bitwise/shift ops fix#143
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates MLIR codegen and lit coverage to validate the corrected handling of bytesN bitwise (& | ^ ~) and shift (<< >>) operations, and removes a couple of semantic tests from the “expected failures” list now that they pass.
Changes:
- Update
SolidityToMLIRPassto emitsol.{and,or,xor,shl,shr,not}directly on!sol.fixedbytes<N>operands (and allow shift RHS to stay in its “mobile” integer type). - Refresh existing FileCheck expectations for
bytes/fixedbytesbitwise and shift lowering (both Sol and EVM pipelines). - Add new
fixedbytes.sollit tests (Sol + EVM) covering comparisons, bitwise ops, unary~, shifts, and mixed-size fixed-bytes operands; remove now-passing semtests from the MLIR failure list.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| test/mlirSemtestFailures.txt | Removes two tests from the expected-MLIR-failures list because they now pass. |
| test/lit/mlirCodegen/shift-bytes.sol | Updates checks to expect direct sol.shl/sol.shr on !sol.fixedbytes<20> rather than cast-to-int shims. |
| test/lit/mlirCodegen/fixedbytes.sol | New lit test covering bytesN comparisons/bitwise/shift/unary-not (Sol pipeline). |
| test/lit/mlirCodegen/EVM/shift-bytes.sol | Updates EVM-lowering checks for fixed-bytes shifts to match new lowering pattern. |
| test/lit/mlirCodegen/EVM/fixedbytes.sol | New lit test covering bytesN comparisons/bitwise/shift/unary-not (EVM pipeline). |
| test/lit/mlirCodegen/EVM/arith.sol | Updates expected lowering for bytes4 bitwise-not and some shift-related masking behavior. |
| test/lit/mlirCodegen/bytes.sol | Updates checks to expect sol.and/or/xor directly on !sol.fixedbytes<5> rather than int casts. |
| test/lit/mlirCodegen/arith.sol | Updates checks to reflect direct sol.not on !sol.fixedbytes<4> and updated shift op typing. |
| libsolidity/codegen/mlir/SolidityToMLIR.cpp | Core codegen change: stop converting bytesN to ints for bitwise/shift ops; emit ops directly with appropriate result/RHS typing. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
abinavpp
approved these changes
Jun 8, 2026
vladimirradosavljevic
approved these changes
Jun 8, 2026
vladimirradosavljevic
left a comment
Contributor
There was a problem hiding this comment.
LGTM. Can we add tests for ByteType?
3f86f2e to
2cb9f36
Compare
Contributor
Author
Yes, but it doesn’t seem easy to generate such a test from Solidity. I’ve created a test directly from the Sol dialect: matter-labs/solx-llvm#87 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
matter-labs/solx-llvm#86