From 68986a58b6df442b1204558a85ca4b29f61c50a0 Mon Sep 17 00:00:00 2001 From: chriseth Date: Fri, 13 Sep 2019 18:09:09 +0200 Subject: [PATCH 1/2] Test. --- .../side_effects_in_for_condition.yul | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 test/libyul/yulOptimizerTests/expressionSimplifier/side_effects_in_for_condition.yul diff --git a/test/libyul/yulOptimizerTests/expressionSimplifier/side_effects_in_for_condition.yul b/test/libyul/yulOptimizerTests/expressionSimplifier/side_effects_in_for_condition.yul new file mode 100644 index 000000000..7e181a097 --- /dev/null +++ b/test/libyul/yulOptimizerTests/expressionSimplifier/side_effects_in_for_condition.yul @@ -0,0 +1,13 @@ +{ + for {} div(create(0, 1, 0), shl(msize(), 1)) {} + { + } +} +// ==== +// step: expressionSimplifier +// EVMVersion: >byzantium +// ---- +// { +// for { } div(create(0, 1, 0), shl(msize(), 1)) { } +// { } +// } From c224b09bb35c67fe2abadfb2f0f40b6fd2078e84 Mon Sep 17 00:00:00 2001 From: chriseth Date: Fri, 13 Sep 2019 18:09:16 +0200 Subject: [PATCH 2/2] Fix reordering bug in optimizer. --- Changelog.md | 1 + libevmasm/RuleList.h | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Changelog.md b/Changelog.md index 976ee721a..519e11559 100644 --- a/Changelog.md +++ b/Changelog.md @@ -14,6 +14,7 @@ Compiler Features: Bugfixes: * Fix internal error when popping a dynamic storage array of mappings. + * Yul Optimizer: Fix reordering bug in connection with shifted one and mul/div-instructions in for loop conditions. ### 0.5.11 (2019-08-12) diff --git a/libevmasm/RuleList.h b/libevmasm/RuleList.h index f2422ce58..58e773f30 100644 --- a/libevmasm/RuleList.h +++ b/libevmasm/RuleList.h @@ -475,7 +475,8 @@ std::vector> simplificationRuleListPart7( [=]() -> Pattern { return {Instruction::SHL, {Y, X}}; }, - false + // Actually only changes the order, does not remove. + true }); rules.push_back({ // MUL(SHL(X, 1), Y) -> SHL(X, Y) @@ -492,7 +493,8 @@ std::vector> simplificationRuleListPart7( [=]() -> Pattern { return {Instruction::SHR, {Y, X}}; }, - false + // Actually only changes the order, does not remove. + true }); std::function feasibilityFunction = [=]() {