diff --git a/libevmasm/RuleList.h b/libevmasm/RuleList.h index 1e3fd7800..c2cf1eef3 100644 --- a/libevmasm/RuleList.h +++ b/libevmasm/RuleList.h @@ -583,9 +583,7 @@ std::vector> simplificationRuleListPart7( Builtins::BYTE(A, Builtins::SHR(B, X)), [=]() -> Pattern { return Word(0); }, true, - [=] { - return B.d() % 8 == 0 && A.d() < Pattern::WordSize / 8 && B.d() <= Pattern::WordSize && A.d() < B.d() / 8; - } + [=] { return A.d() < B.d() / 8; } }); rules.push_back({ diff --git a/test/formal/combine_byte_shr_2.py b/test/formal/combine_byte_shr_2.py index d74114e85..4f9be05a4 100644 --- a/test/formal/combine_byte_shr_2.py +++ b/test/formal/combine_byte_shr_2.py @@ -3,7 +3,7 @@ from opcodes import * """ byte(A, shr(B, X)) -given B % 8 == 0 && A < n_bits/8 && B <= n_bits && A < B / 8 +given A < B / 8 -> 0 """ @@ -22,9 +22,6 @@ nonopt = BYTE(A, SHR(B, X)) # Optimized result opt = 0 -rule.require(B % 8 == 0) -rule.require(ULT(A, n_bits/8)) -rule.require(ULE(B, n_bits)) rule.require(ULT(A, DIV(B,8))) rule.check(nonopt, opt) diff --git a/test/libyul/yulOptimizerTests/expressionSimplifier/byte_after_shr_non_mul_of_8.yul b/test/libyul/yulOptimizerTests/expressionSimplifier/byte_after_shr_non_mul_of_8.yul new file mode 100644 index 000000000..e7c7bbf88 --- /dev/null +++ b/test/libyul/yulOptimizerTests/expressionSimplifier/byte_after_shr_non_mul_of_8.yul @@ -0,0 +1,9 @@ +{ + sstore(0, byte(0, shr(0x9, calldataload(0)))) +} +// ==== +// EVMVersion: >=constantinople +// ---- +// step: expressionSimplifier +// +// { sstore(0, 0) }