Fix optimization specific SREM edge case (#527)

Existing test coverage didn't catch a signed remainder overflow
semantics edge case behavior where at least one the operators is being
constant folded by LLVM instead of solc. This PR fixes the SREM
translation bug and adds missing test coverage for division ops with
constants.

Closes #524

---------

Signed-off-by: xermicus <cyrill@parity.io>
This commit is contained in:
xermicus authored and GitHub committed 2026-05-28 09:01:41 +02:00
1 parent 62a62770e3
commit 40e97d11eb
23 files changed
+1336 -21

No files matched your search

+8
View File
@@ -9,8 +9,16 @@
- Updated `LLVM` from `21.1.8` to LLVM `22.1.4`
### Added
- Support for solc v0.8.35.
### Fixed
- A constant folding bug causing incorrect translation of a signed remainder edge case. The affected pattern (Solidity % or Yul smod):
- SREM over the two constant operands `type(int256).min` and `-1`.
- At least one of the two constants needs folding (i.e. not just `type(int256).min % -1`),
and is written specifically such that solc doesn't fold but LLVM does, resulting in UB (signed-overflow).
## v1.1.0
Supported `polkadot-sdk` rev: `2603`