diff --git a/Changelog.md b/Changelog.md index 7f73f4f60..0e41cf260 100644 --- a/Changelog.md +++ b/Changelog.md @@ -5,6 +5,7 @@ Language Features: Compiler Features: * Low-Level Inliner: Inline ordinary jumps to small blocks and jumps to small blocks that terminate. + * Yul Optimizer: Added a new step FunctionSpecializer, that specializes a function with its literal arguments. Bugfixes: diff --git a/docs/yul.rst b/docs/yul.rst index 27e35cfa0..2f9b0f98e 100644 --- a/docs/yul.rst +++ b/docs/yul.rst @@ -1125,6 +1125,7 @@ Abbreviation Full name ``i`` ``FullInliner`` ``g`` ``FunctionGrouper`` ``h`` ``FunctionHoister`` +``F`` ``FunctionSpecializer`` ``T`` ``LiteralRematerialiser`` ``L`` ``LoadResolver`` ``M`` ``LoopInvariantCodeMotion`` diff --git a/libsolidity/interface/OptimiserSettings.h b/libsolidity/interface/OptimiserSettings.h index a1d6bbf55..3df99325e 100644 --- a/libsolidity/interface/OptimiserSettings.h +++ b/libsolidity/interface/OptimiserSettings.h @@ -45,7 +45,7 @@ struct OptimiserSettings "xarulrul" // Prune a bit more in SSA "xarrcL" // Turn into SSA again and simplify "gvif" // Run full inliner - "CTUcarrLsTOtfDncarrIulc" // SSA plus simplify + "CTUcarrLsTFOtfDncarrIulc" // SSA plus simplify "]" "jmuljuljul VcTOcul jmul"; // Make source short and pretty diff --git a/libsolutil/CommonData.h b/libsolutil/CommonData.h index a381767eb..3ec5b5739 100644 --- a/libsolutil/CommonData.h +++ b/libsolutil/CommonData.h @@ -93,10 +93,8 @@ template inline std::vector operator+(std::vector&& _a, std::vector&& _b) { std::vector ret(std::move(_a)); - if (&_a == &_b) - ret += ret; - else - ret += std::move(_b); + assert(&_a != &_b); + ret += std::move(_b); return ret; } diff --git a/libyul/CMakeLists.txt b/libyul/CMakeLists.txt index df7f087e1..f33067bbb 100644 --- a/libyul/CMakeLists.txt +++ b/libyul/CMakeLists.txt @@ -131,6 +131,8 @@ add_library(yul optimiser/FunctionGrouper.h optimiser/FunctionHoister.cpp optimiser/FunctionHoister.h + optimiser/FunctionSpecializer.cpp + optimiser/FunctionSpecializer.h optimiser/InlinableExpressionFunctionFinder.cpp optimiser/InlinableExpressionFunctionFinder.h optimiser/KnowledgeBase.cpp diff --git a/libyul/optimiser/ASTCopier.cpp b/libyul/optimiser/ASTCopier.cpp index 358811358..8c0b3acfa 100644 --- a/libyul/optimiser/ASTCopier.cpp +++ b/libyul/optimiser/ASTCopier.cpp @@ -171,3 +171,9 @@ TypedName ASTCopier::translate(TypedName const& _typedName) return TypedName{_typedName.location, translateIdentifier(_typedName.name), _typedName.type}; } +YulString FunctionCopier::translateIdentifier(YulString _name) +{ + if (m_translations.count(_name)) + return m_translations.at(_name); + return _name; +} diff --git a/libyul/optimiser/ASTCopier.h b/libyul/optimiser/ASTCopier.h index 4cf69b0b7..db9d72af3 100644 --- a/libyul/optimiser/ASTCopier.h +++ b/libyul/optimiser/ASTCopier.h @@ -29,6 +29,7 @@ #include #include #include +#include namespace solidity::yul { @@ -117,5 +118,22 @@ std::vector ASTCopier::translateVector(std::vector const& _values) return translated; } +/// Helper class that creates a copy of the function definition, replacing the names of the variable +/// declarations with new names. +class FunctionCopier: public ASTCopier +{ +public: + FunctionCopier( + std::map const& _translations + ): + m_translations(_translations) + {} + using ASTCopier::operator(); + YulString translateIdentifier(YulString _name) override; +private: + /// A mapping between old and new names. We replace the names of variable declarations contained + /// in the mapping with their new names. + std::map const& m_translations; +}; } diff --git a/libyul/optimiser/FunctionSpecializer.cpp b/libyul/optimiser/FunctionSpecializer.cpp new file mode 100644 index 000000000..65f092487 --- /dev/null +++ b/libyul/optimiser/FunctionSpecializer.cpp @@ -0,0 +1,158 @@ +/* + This file is part of solidity. + + solidity is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + solidity is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with solidity. If not, see . +*/ +// SPDX-License-Identifier: GPL-3.0 + +#include + +#include +#include +#include +#include + +#include +#include +#include + +#include +#include + +#include + +using namespace std; +using namespace solidity::util; +using namespace solidity::yul; + +FunctionSpecializer::LiteralArguments FunctionSpecializer::specializableArguments( + FunctionCall const& _f +) +{ + auto heuristic = [&](Expression const& _e) -> optional + { + if (holds_alternative(_e)) + return ASTCopier{}.translate(_e); + return nullopt; + }; + + return applyMap(_f.arguments, heuristic); +} + +void FunctionSpecializer::operator()(FunctionCall& _f) +{ + ASTModifier::operator()(_f); + + // TODO When backtracking is implemented, the restriction of recursive functions can be lifted. + if ( + m_dialect.builtin(_f.functionName.name) || + m_recursiveFunctions.count(_f.functionName.name) + ) + return; + + LiteralArguments arguments = specializableArguments(_f); + + if (ranges::any_of(arguments, [](auto& _a) { return _a.has_value(); })) + { + YulString oldName = move(_f.functionName.name); + auto newName = m_nameDispenser.newName(oldName); + + m_oldToNewMap[oldName].emplace_back(make_pair(newName, arguments)); + + _f.functionName.name = newName; + _f.arguments = util::filter( + _f.arguments, + applyMap(arguments, [](auto& _a) { return !_a; }) + ); + } +} + +FunctionDefinition FunctionSpecializer::specialize( + FunctionDefinition const& _f, + YulString _newName, + FunctionSpecializer::LiteralArguments _arguments +) +{ + yulAssert(_arguments.size() == _f.parameters.size(), ""); + + map translatedNames = applyMap( + NameCollector{_f, NameCollector::OnlyVariables}.names(), + [&](auto& _name) -> pair + { + return make_pair(_name, m_nameDispenser.newName(_name)); + }, + map{} + ); + + FunctionDefinition newFunction = get(FunctionCopier{translatedNames}(_f)); + + // Function parameters that will be specialized inside the body are converted into variable + // declarations. + vector missingVariableDeclarations; + for (auto&& [index, argument]: _arguments | ranges::views::enumerate) + if (argument) + missingVariableDeclarations.emplace_back( + VariableDeclaration{ + _f.location, + vector{newFunction.parameters[index]}, + make_unique(move(*argument)) + } + ); + + newFunction.body.statements = + move(missingVariableDeclarations) + move(newFunction.body.statements); + + // Only take those indices that cannot be specialized, i.e., whose value is `nullopt`. + newFunction.parameters = + util::filter( + newFunction.parameters, + applyMap(_arguments, [&](auto const& _v) { return !_v; }) + ); + + newFunction.name = move(_newName); + + return newFunction; +} + +void FunctionSpecializer::run(OptimiserStepContext& _context, Block& _ast) +{ + FunctionSpecializer f{ + CallGraphGenerator::callGraph(_ast).recursiveFunctions(), + _context.dispenser, + _context.dialect + }; + f(_ast); + + iterateReplacing(_ast.statements, [&](Statement& _s) -> optional> + { + if (holds_alternative(_s)) + { + auto& functionDefinition = get(_s); + + if (f.m_oldToNewMap.count(functionDefinition.name)) + { + vector out = applyMap( + f.m_oldToNewMap.at(functionDefinition.name), + [&](auto& _p) -> Statement + { + return f.specialize(functionDefinition, move(_p.first), move(_p.second)); + } + ); + return move(out) + make_vector(move(functionDefinition)); + } + } + + return nullopt; + }); +} diff --git a/libyul/optimiser/FunctionSpecializer.h b/libyul/optimiser/FunctionSpecializer.h new file mode 100644 index 000000000..b922ece8b --- /dev/null +++ b/libyul/optimiser/FunctionSpecializer.h @@ -0,0 +1,113 @@ +/* + This file is part of solidity. + + solidity is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + solidity is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with solidity. If not, see . +*/ +// SPDX-License-Identifier: GPL-3.0 + +#pragma once + +#include +#include +#include + +#include +#include + +#include +#include +#include + +namespace solidity::yul +{ + +/** + * FunctionSpecializer: Optimiser step that specializes the function with its literal arguments. + * + * If a function, say, `function f(a, b) { sstore (a, b)}`, is called with literal arguments, for + * example, `f(x, 5)`, where `x` is an identifier, it could be specialized by creating a new + * function `f_1` that takes only one argument, i.e., + * + * function f_1(a_1) { + * let b_1 := 5 + * sstore(a_1, b_1) + * } + * + * Other optimization steps will be able to make more simplifications to the function. The + * optimization step is mainly useful for functions that would not be inlined. + * + * Prerequisites: Disambiguator, FunctionHoister + * + * LiteralRematerialiser is recommended as a prerequisite, even though it's not required for + * correctness. + */ +class FunctionSpecializer: public ASTModifier +{ +public: + /// A vector of function-call arguments. An element 'has value' if it's a literal, and the + /// corresponding Expression would be the literal. + using LiteralArguments = std::vector>; + + static constexpr char const* name{"FunctionSpecializer"}; + static void run(OptimiserStepContext& _context, Block& _ast); + + using ASTModifier::operator(); + void operator()(FunctionCall& _f) override; + +private: + explicit FunctionSpecializer( + std::set _recursiveFunctions, + NameDispenser& _nameDispenser, + Dialect const& _dialect + ): + m_recursiveFunctions(std::move(_recursiveFunctions)), + m_nameDispenser(_nameDispenser), + m_dialect(_dialect) + {} + /// Returns a vector of Expressions, where the index `i` is an expression if the function's + /// `i`-th argument can be specialized, nullopt otherwise. + LiteralArguments specializableArguments(FunctionCall const& _f); + /// Given a function definition `_f` and its arguments `_arguments`, of which, at least one is a + /// literal, this function returns a new function with the literal arguments specialized. + /// + /// Note that the returned function definition will have new (and unique) names, for both the + /// function and variable declarations to retain the properties enforced by the Disambiguator. + /// + /// For example, if `_f` is the function `function f(a, b, c) -> d { sstore(a, b) }`, + /// `_arguments` is the vector of literals `{1, 2, nullopt}` and the @param, `_newName` has + /// value `f_1`, the returned function could be: + /// + /// function f_1(c_2) -> d_3 { + /// let a_4 := 1 + /// let b_5 := 2 + /// sstore(a_4, b_5) + /// } + /// + FunctionDefinition specialize( + FunctionDefinition const& _f, + YulString _newName, + FunctionSpecializer::LiteralArguments _arguments + ); + + /// A mapping between the old function name and a pair of new function name and its arguments. + /// Note that at least one of the argument will have a literal value. + std::map>> m_oldToNewMap; + /// We skip specializing recursive functions. Need backtracking to properly deal with them. + std::set const m_recursiveFunctions; + + NameDispenser& m_nameDispenser; + Dialect const& m_dialect; +}; + +} diff --git a/libyul/optimiser/NameCollector.cpp b/libyul/optimiser/NameCollector.cpp index bc0fccda4..69e627fbb 100644 --- a/libyul/optimiser/NameCollector.cpp +++ b/libyul/optimiser/NameCollector.cpp @@ -36,7 +36,8 @@ void NameCollector::operator()(VariableDeclaration const& _varDecl) void NameCollector::operator ()(FunctionDefinition const& _funDef) { - m_names.emplace(_funDef.name); + if (m_collectWhat == VariablesAndFunctions) + m_names.emplace(_funDef.name); for (auto const& arg: _funDef.parameters) m_names.emplace(arg.name); for (auto const& ret: _funDef.returnVariables) diff --git a/libyul/optimiser/NameCollector.h b/libyul/optimiser/NameCollector.h index 0bedab3f8..17afcec1b 100644 --- a/libyul/optimiser/NameCollector.h +++ b/libyul/optimiser/NameCollector.h @@ -35,11 +35,26 @@ namespace solidity::yul class NameCollector: public ASTWalker { public: - explicit NameCollector(Block const& _block) + enum CollectWhat { VariablesAndFunctions, OnlyVariables }; + + explicit NameCollector( + Block const& _block, + CollectWhat _collectWhat = VariablesAndFunctions + ): + m_collectWhat(_collectWhat) { (*this)(_block); } + explicit NameCollector( + FunctionDefinition const& _functionDefinition, + CollectWhat _collectWhat = VariablesAndFunctions + ): + m_collectWhat(_collectWhat) + { + (*this)(_functionDefinition); + } + using ASTWalker::operator (); void operator()(VariableDeclaration const& _varDecl) override; void operator()(FunctionDefinition const& _funDef) override; @@ -47,6 +62,7 @@ public: std::set names() const { return m_names; } private: std::set m_names; + CollectWhat m_collectWhat = VariablesAndFunctions; }; /** diff --git a/libyul/optimiser/Suite.cpp b/libyul/optimiser/Suite.cpp index 3f59e89e6..89dff11ab 100644 --- a/libyul/optimiser/Suite.cpp +++ b/libyul/optimiser/Suite.cpp @@ -41,6 +41,7 @@ #include #include #include +#include #include #include #include @@ -192,6 +193,7 @@ map> const& OptimiserSuite::allSteps() FullInliner, FunctionGrouper, FunctionHoister, + FunctionSpecializer, LiteralRematerialiser, LoadResolver, LoopInvariantCodeMotion, @@ -231,6 +233,7 @@ map const& OptimiserSuite::stepNameToAbbreviationMap() {FullInliner::name, 'i'}, {FunctionGrouper::name, 'g'}, {FunctionHoister::name, 'h'}, + {FunctionSpecializer::name, 'F'}, {LiteralRematerialiser::name, 'T'}, {LoadResolver::name, 'L'}, {LoopInvariantCodeMotion::name, 'M'}, diff --git a/test/cmdlineTests/evm_to_wasm/output b/test/cmdlineTests/evm_to_wasm/output index f8423bafe..fa454f80f 100644 --- a/test/cmdlineTests/evm_to_wasm/output +++ b/test/cmdlineTests/evm_to_wasm/output @@ -14,9 +14,17 @@ object "object" { code { function main() { - let _1 := 0 - mstore_internal(0:i32, _1, _1, _1, _1) - mstore_internal(32:i32, _1, _1, _1, 1) + let hi := i64.shl(i64.extend_i32_u(bswap32(i32.wrap_i64(0))), 32) + let y := i64.or(hi, i64.extend_i32_u(bswap32(i32.wrap_i64(i64.shr_u(0, 32))))) + i64.store(0:i32, y) + i64.store(i32.add(0:i32, 8:i32), y) + i64.store(i32.add(0:i32, 16:i32), y) + i64.store(i32.add(0:i32, 24:i32), y) + i64.store(32:i32, y) + i64.store(i32.add(32:i32, 8:i32), y) + i64.store(i32.add(32:i32, 16:i32), y) + let hi_1 := i64.shl(i64.extend_i32_u(bswap32(i32.wrap_i64(1))), 32) + i64.store(i32.add(32:i32, 24:i32), i64.or(hi_1, i64.extend_i32_u(bswap32(i32.wrap_i64(i64.shr_u(1, 32)))))) eth.storageStore(0:i32, 32:i32) } function bswap16(x:i32) -> y:i32 @@ -28,24 +36,12 @@ object "object" { let hi:i32 := i32.shl(bswap16(x), 16:i32) y := i32.or(hi, bswap16(i32.shr_u(x, 16:i32))) } - function bswap64(x) -> y - { - let hi := i64.shl(i64.extend_i32_u(bswap32(i32.wrap_i64(x))), 32) - y := i64.or(hi, i64.extend_i32_u(bswap32(i32.wrap_i64(i64.shr_u(x, 32))))) - } - function mstore_internal(pos:i32, y1, y2, y3, y4) - { - i64.store(pos, bswap64(y1)) - i64.store(i32.add(pos, 8:i32), bswap64(y2)) - i64.store(i32.add(pos, 16:i32), bswap64(y3)) - i64.store(i32.add(pos, 24:i32), bswap64(y4)) - } } } Binary representation: -0061736d01000000011b0560000060017e017e60017f017f60057f7e7e7e7e0060027f7f0002190108657468657265756d0c73746f7261676553746f7265000403060500020201030503010001060100071102066d656d6f72790200046d61696e00010ac001052901017e0240420021004100200020002000200010054120200020002000420110054100412010000b0b1f01017f024020004108744180fe0371200041087641ff01717221010b20010b1e01027f02402000100241107421022002200041107610027221010b20010b2201027e02402000a71003ad422086210220022000422088a71003ad8421010b20010b32000240200020011004370000200041086a20021004370000200041106a20031004370000200041186a200410043700000b0b +0061736d01000000010e0360000060017f017f60027f7f0002190108657468657265756d0c73746f7261676553746f726500020304030001010503010001060100071102066d656d6f72790200046d61696e00010ac70103850101037e02404200a71003ad422086210020004200422088a71003ad84210141002001370000410041086a2001370000410041106a2001370000410041186a200137000041202001370000412041086a2001370000412041106a20013700004201a71003ad4220862102412041186a20024201422088a71003ad843700004100412010000b0b1f01017f024020004108744180fe0371200041087641ff01717221010b20010b1e01027f02402000100241107421022002200041107610027221010b20010b Text representation: (module @@ -54,11 +50,21 @@ Text representation: (export "main" (func $main)) (func $main - (local $_1 i64) + (local $hi i64) + (local $y i64) + (local $hi_1 i64) (block $label_ - (local.set $_1 (i64.const 0)) - (call $mstore_internal (i32.const 0) (local.get $_1) (local.get $_1) (local.get $_1) (local.get $_1)) - (call $mstore_internal (i32.const 32) (local.get $_1) (local.get $_1) (local.get $_1) (i64.const 1)) + (local.set $hi (i64.shl (i64.extend_i32_u (call $bswap32 (i32.wrap_i64 (i64.const 0)))) (i64.const 32))) + (local.set $y (i64.or (local.get $hi) (i64.extend_i32_u (call $bswap32 (i32.wrap_i64 (i64.shr_u (i64.const 0) (i64.const 32))))))) + (i64.store (i32.const 0) (local.get $y)) + (i64.store (i32.add (i32.const 0) (i32.const 8)) (local.get $y)) + (i64.store (i32.add (i32.const 0) (i32.const 16)) (local.get $y)) + (i64.store (i32.add (i32.const 0) (i32.const 24)) (local.get $y)) + (i64.store (i32.const 32) (local.get $y)) + (i64.store (i32.add (i32.const 32) (i32.const 8)) (local.get $y)) + (i64.store (i32.add (i32.const 32) (i32.const 16)) (local.get $y)) + (local.set $hi_1 (i64.shl (i64.extend_i32_u (call $bswap32 (i32.wrap_i64 (i64.const 1)))) (i64.const 32))) + (i64.store (i32.add (i32.const 32) (i32.const 24)) (i64.or (local.get $hi_1) (i64.extend_i32_u (call $bswap32 (i32.wrap_i64 (i64.shr_u (i64.const 1) (i64.const 32))))))) (call $eth.storageStore (i32.const 0) (i32.const 32)) ) ) @@ -87,31 +93,4 @@ Text representation: (local.get $y) ) -(func $bswap64 - (param $x i64) - (result i64) - (local $y i64) - (local $hi i64) - (block $label__3 - (local.set $hi (i64.shl (i64.extend_i32_u (call $bswap32 (i32.wrap_i64 (local.get $x)))) (i64.const 32))) - (local.set $y (i64.or (local.get $hi) (i64.extend_i32_u (call $bswap32 (i32.wrap_i64 (i64.shr_u (local.get $x) (i64.const 32))))))) - - ) - (local.get $y) -) - -(func $mstore_internal - (param $pos i32) - (param $y1 i64) - (param $y2 i64) - (param $y3 i64) - (param $y4 i64) - (block $label__4 - (i64.store (local.get $pos) (call $bswap64 (local.get $y1))) - (i64.store (i32.add (local.get $pos) (i32.const 8)) (call $bswap64 (local.get $y2))) - (i64.store (i32.add (local.get $pos) (i32.const 16)) (call $bswap64 (local.get $y3))) - (i64.store (i32.add (local.get $pos) (i32.const 24)) (call $bswap64 (local.get $y4))) - ) -) - ) diff --git a/test/cmdlineTests/evm_to_wasm_break/output b/test/cmdlineTests/evm_to_wasm_break/output index 370eff727..0eaf827d2 100644 --- a/test/cmdlineTests/evm_to_wasm_break/output +++ b/test/cmdlineTests/evm_to_wasm_break/output @@ -24,68 +24,64 @@ object "object" { code { function main() { - let _1 := 0 - let x, x_1, x_2, x_3 := calldataload(_1, _1, _1, _1) + let x, x_1, x_2, x_3 := calldataload() let x_4 := x let x_5 := x_1 let x_6 := x_2 let x_7 := x_3 - let _2 := 1 - let _3:i32 := i32.eqz(i32.eqz(i64.eqz(i64.or(i64.or(_1, _1), i64.or(_1, _2))))) + let _1:i32 := i32.eqz(i32.eqz(i64.eqz(i64.or(i64.or(0, 0), i64.or(0, 1))))) for { } - i32.eqz(_3) + i32.eqz(_1) { - let x_8, x_9, x_10, x_11 := add(x_4, x_5, x_6, x_7, _1, _1, _1, _2) + let x_8, x_9, x_10, x_11 := add(x_4, x_5, x_6, x_7) x_4 := x_8 x_5 := x_9 x_6 := x_10 x_7 := x_11 } { - let _4, _5, _6, _7 := iszero_887(_1, _1, _1, lt(x_4, x_5, x_6, x_7, _1, _1, _1, 10)) - if i32.eqz(i64.eqz(i64.or(i64.or(_4, _5), i64.or(_6, _7)))) { break } - let _8, _9, _10, _11 := eq_888(x_4, x_5, x_6, x_7, _1, _1, _1, 2) - if i32.eqz(i64.eqz(i64.or(i64.or(_8, _9), i64.or(_10, _11)))) { break } - let _12, _13, _14, _15 := eq_888(x_4, x_5, x_6, x_7, _1, _1, _1, 4) - if i32.eqz(i64.eqz(i64.or(i64.or(_12, _13), i64.or(_14, _15)))) { continue } + let _2, _3, _4, _5 := iszero_1300_2121(lt(x_4, x_5, x_6, x_7)) + if i32.eqz(i64.eqz(i64.or(i64.or(_2, _3), i64.or(_4, _5)))) { break } + let _6, _7, _8, _9 := eq_740_2122(x_4, x_5, x_6, x_7) + if i32.eqz(i64.eqz(i64.or(i64.or(_6, _7), i64.or(_8, _9)))) { break } + let _10, _11, _12, _13 := eq_741_2123(x_4, x_5, x_6, x_7) + if i32.eqz(i64.eqz(i64.or(i64.or(_10, _11), i64.or(_12, _13)))) { continue } } - sstore(_1, _1, _1, _1, x_4, x_5, x_6, x_7) + sstore(x_4, x_5, x_6, x_7) } - function add_carry(x, y, c) -> r, r_c + function add(x1, x2, x3, x4) -> r1, r2, r3, r4 { - let t := i64.add(x, y) - r := i64.add(t, c) - r_c := i64.extend_i32_u(i32.or(i64.lt_u(t, x), i64.lt_u(r, t))) - } - function add(x1, x2, x3, x4, y1, y2, y3, y4) -> r1, r2, r3, r4 - { - let t := i64.add(x4, y4) + let t := i64.add(x4, 1) r4 := i64.add(t, 0) - let r3_1, carry := add_carry(x3, y3, i64.extend_i32_u(i32.or(i64.lt_u(t, x4), i64.lt_u(r4, t)))) - r3 := r3_1 - let r2_1, carry_1 := add_carry(x2, y2, carry) - r2 := r2_1 - let r1_1, carry_2 := add_carry(x1, y1, carry_1) - r1 := r1_1 + let t_1 := i64.add(x3, 0) + r3 := i64.add(t_1, i64.extend_i32_u(i32.or(i64.lt_u(t, x4), i64.lt_u(r4, t)))) + let t_2 := i64.add(x2, 0) + r2 := i64.add(t_2, i64.extend_i32_u(i32.or(i64.lt_u(t_1, x3), i64.lt_u(r3, t_1)))) + r1 := i64.add(i64.add(x1, 0), i64.extend_i32_u(i32.or(i64.lt_u(t_2, x2), i64.lt_u(r2, t_2)))) } - function iszero_887(x1, x2, x3, x4) -> r1, r2, r3, r4 + function iszero_1300_2121(x4) -> r1, r2, r3, r4 { - r4 := i64.extend_i32_u(i64.eqz(i64.or(i64.or(x1, x2), i64.or(x3, x4)))) + r4 := i64.extend_i32_u(i64.eqz(i64.or(i64.or(0, 0), i64.or(0, x4)))) } - function eq_888(x1, x2, x3, x4, y1, y2, y3, y4) -> r1, r2, r3, r4 + function eq_740_2122(x1, x2, x3, x4) -> r1, r2, r3, r4 { - r4 := i64.extend_i32_u(i32.and(i64.eq(x1, y1), i32.and(i64.eq(x2, y2), i32.and(i64.eq(x3, y3), i64.eq(x4, y4))))) + r4 := i64.extend_i32_u(i32.and(i64.eq(x1, 0), i32.and(i64.eq(x2, 0), i32.and(i64.eq(x3, 0), i64.eq(x4, 2))))) } - function lt(x1, x2, x3, x4, y1, y2, y3, y4) -> z4 + function eq_741_2123(x1, x2, x3, x4) -> r1, r2, r3, r4 + { + r4 := i64.extend_i32_u(i32.and(i64.eq(x1, 0), i32.and(i64.eq(x2, 0), i32.and(i64.eq(x3, 0), i64.eq(x4, 4))))) + } + function lt(x1, x2, x3, x4) -> z4 { let z:i32 := false - let _1:i32 := 0xffffffff:i32 - switch i32.select(_1, i64.ne(x1, y1), i64.lt_u(x1, y1)) + let _1 := 0 + let _2:i32 := 0xffffffff:i32 + switch i32.select(_2, i64.ne(x1, _1), i64.lt_u(x1, _1)) case 0:i32 { - switch i32.select(_1, i64.ne(x2, y2), i64.lt_u(x2, y2)) + switch i32.select(_2, i64.ne(x2, _1), i64.lt_u(x2, _1)) case 0:i32 { - switch i32.select(_1, i64.ne(x3, y3), i64.lt_u(x3, y3)) - case 0:i32 { z := i64.lt_u(x4, y4) } + switch i32.select(_2, i64.ne(x3, _1), i64.lt_u(x3, _1)) + case 0:i32 { z := i64.lt_u(x4, 10) } case 1:i32 { z := 0:i32 } default { z := 1:i32 } } @@ -96,11 +92,18 @@ object "object" { default { z := 1:i32 } z4 := i64.extend_i32_u(z) } - function u256_to_i32(x1, x2, x3, x4) -> v:i32 + function u256_to_i32_744() -> v:i32 { - if i64.ne(0, i64.or(i64.or(x1, x2), x3)) { unreachable() } - if i64.ne(0, i64.shr_u(x4, 32)) { unreachable() } - v := i32.wrap_i64(x4) + if i64.ne(0, i64.or(i64.or(0, 0), 0)) { unreachable() } + if i64.ne(0, i64.shr_u(32, 32)) { unreachable() } + v := i32.wrap_i64(32) + } + function u256_to_i32() -> v:i32 + { + let _1 := 0 + if i64.ne(_1, i64.or(i64.or(_1, _1), _1)) { unreachable() } + if i64.ne(_1, i64.shr_u(_1, 32)) { unreachable() } + v := i32.wrap_i64(_1) } function bswap16(x:i32) -> y:i32 { @@ -116,59 +119,66 @@ object "object" { let hi := i64.shl(i64.extend_i32_u(bswap32(i32.wrap_i64(x))), 32) y := i64.or(hi, i64.extend_i32_u(bswap32(i32.wrap_i64(i64.shr_u(x, 32))))) } - function calldataload(x1, x2, x3, x4) -> z1, z2, z3, z4 + function calldataload() -> z1, z2, z3, z4 { let cds:i32 := eth.getCallDataSize() let _1 := 0 - let destination:i32 := u256_to_i32(_1, _1, _1, _1) - let offset:i32 := u256_to_i32(x1, x2, x3, x4) - let requested_size:i32 := u256_to_i32(_1, _1, _1, 32) + if i64.ne(_1, i64.or(i64.or(_1, _1), _1)) { unreachable() } + if i64.ne(_1, i64.shr_u(_1, 32)) { unreachable() } + let v:i32 := i32.wrap_i64(_1) + let offset:i32 := u256_to_i32() + let requested_size:i32 := u256_to_i32_744() if i32.gt_u(offset, i32.sub(0xffffffff:i32, requested_size)) { eth.revert(0:i32, 0:i32) } let available_size:i32 := i32.sub(cds, offset) if i32.gt_u(offset, cds) { available_size := 0:i32 } let _2:i32 := 0:i32 if i32.gt_u(available_size, _2) { - eth.callDataCopy(destination, offset, available_size) + eth.callDataCopy(v, offset, available_size) } if i32.gt_u(requested_size, available_size) { let _3:i32 := i32.sub(requested_size, available_size) - let _4:i32 := i32.add(destination, available_size) + let _4:i32 := i32.add(v, available_size) let i:i32 := _2 for { } i32.lt_u(i, _3) { i := i32.add(i, 1:i32) } { i32.store8(i32.add(_4, i), _2) } } - let z1_1 := bswap64(i64.load(_2)) - let z2_1 := bswap64(i64.load(i32.add(_2, 8:i32))) - let z3_1 := bswap64(i64.load(i32.add(_2, 16:i32))) - let z4_1 := bswap64(i64.load(i32.add(_2, 24:i32))) + let z1_1, z2_1, z3_1, z4_1 := mload_internal() z1 := z1_1 z2 := z2_1 z3 := z3_1 z4 := z4_1 } - function sstore(x1, x2, x3, x4, y1, y2, y3, y4) + function sstore(y1, y2, y3, y4) { - mstore_internal(0:i32, x1, x2, x3, x4) - mstore_internal(32:i32, y1, y2, y3, y4) + let hi := i64.shl(i64.extend_i32_u(bswap32(i32.wrap_i64(0))), 32) + let y := i64.or(hi, i64.extend_i32_u(bswap32(i32.wrap_i64(i64.shr_u(0, 32))))) + i64.store(0:i32, y) + i64.store(i32.add(0:i32, 8:i32), y) + i64.store(i32.add(0:i32, 16:i32), y) + i64.store(i32.add(0:i32, 24:i32), y) + i64.store(32:i32, bswap64(y1)) + i64.store(i32.add(32:i32, 8:i32), bswap64(y2)) + i64.store(i32.add(32:i32, 16:i32), bswap64(y3)) + i64.store(i32.add(32:i32, 24:i32), bswap64(y4)) eth.storageStore(0:i32, 32:i32) } - function mstore_internal(pos:i32, y1, y2, y3, y4) + function mload_internal() -> z1, z2, z3, z4 { - i64.store(pos, bswap64(y1)) - i64.store(i32.add(pos, 8:i32), bswap64(y2)) - i64.store(i32.add(pos, 16:i32), bswap64(y3)) - i64.store(i32.add(pos, 24:i32), bswap64(y4)) + z1 := bswap64(i64.load(0:i32)) + z2 := bswap64(i64.load(i32.add(0:i32, 8:i32))) + z3 := bswap64(i64.load(i32.add(0:i32, 16:i32))) + z4 := bswap64(i64.load(i32.add(0:i32, 24:i32))) } } } Binary representation: -0061736d0100000001530c6000006000017f60017e017e60037e7e7e017e60047e7e7e7e017e60047e7e7e7e017f60087e7e7e7e7e7e7e7e0060087e7e7e7e7e7e7e7e017e60017f017f60057f7e7e7e7e0060027f7f0060037f7f7f00025e0408657468657265756d0c73746f7261676553746f7265000a08657468657265756d06726576657274000a08657468657265756d0f67657443616c6c4461746153697a65000108657468657265756d0c63616c6c44617461436f7079000b030e0d0003070407070508080204060905030100010610037e0142000b7e0142000b7e0142000b071102066d656d6f72790200046d61696e00040ac0090dcb02030a7e017f107e02404200210002402000200020002000100e21012300210223012103230221040b20012105200221062003210720042108420121092000200084200020098484504545210a02400340200a45450d01024002402000200020002005200620072008200020002000420a10091007210b2300210c2301210d2302210e0b200b200c84200d200e8484504504400c030b0240200520062007200820002000200042021008210f2300211023012111230221120b200f201084201120128484504504400c030b024020052006200720082000200020004204100821132300211423012115230221160b2013201484201520168484504504400c010b0b0240200520062007200820002000200020091006211723002118230121192302211a0b201721052018210620192107201a21080c000b0b20002000200020002005200620072008100f0b0b2901037e0240200020017c2105200520027c21032005200054200320055472ad21040b2004240020030b6c010b7e0240200320077c210c200c42007c210b024020022006200c200354200b200c5472ad1005210d2300210e0b200d210a024020012005200e1005210f230021100b200f2109024020002004201010052111230021120b201121080b20092400200a2401200b240220080b2401047e0240200020018420022003848450ad21070b20052400200624012007240220040b2f01047e02402000200451200120055120022006512003200751717171ad210b0b20092400200a2401200b240220080ba30102017e057f024041002109417f210a0240200a200020045220002004541b210b200b41004604400240200a200120055220012005541b210c200c41004604400240200a200220065220022006541b210d200d41004604402003200754210905200d41014604404100210905410121090b0b0b05200c41014604404100210905410121090b0b0b05200b41014604404100210905410121090b0b0b2009ad21080b20080b2901017f024042002000200184200284520440000b42002003422088520440000b2003a721040b20040b1f01017f024020004108744180fe0371200041087641ff01717221010b20010b1e01027f02402000100b411074210220022000411076100b7221010b20010b2201027e02402000a7100cad422086210220022000422088a7100cad8421010b20010bfc0105047e017f017e087f047e024010022108420021092009200920092009100a210a2000200120022003100a210b2009200920094220100a210c200b417f200c6b4b04404100410010010b2008200b6b210d200b20084b04404100210d0b4100210e200d200e4b0440200a200b200d10030b200c200d4b0440200c200d6b210f200a200d6a2110200e2111024003402011200f49450d010240201020116a200e3a00000b201141016a21110c000b0b0b200e290000100d2112200e41086a290000100d2113200e41106a290000100d2114200e41186a290000100d2115201221042013210520142106201521070b20052400200624012007240220040b230002404100200020012002200310104120200420052006200710104100412010000b0b3200024020002001100d370000200041086a2002100d370000200041106a2003100d370000200041186a2004100d3700000b0b +0061736d010000000130096000006000017e6000017f60017e017e60047e7e7e7e0060047e7e7e7e017e60017f017f60027f7f0060037f7f7f00025e0408657468657265756d0c73746f7261676553746f7265000708657468657265756d06726576657274000708657468657265756d0f67657443616c6c4461746153697a65000208657468657265756d0c63616c6c44617461436f70790008030f0e00050305050502020606030104010503010001061a057e0142000b7e0142000b7e0142000b7f0141000b7f0141000b071102066d656d6f72790200046d61696e00040a8a0a0e8d0203087e017f107e02400240100f21002300210123012102230221030b200021042001210520022106200321074200420084420042018484504545210802400340200845450d010240024020042005200620071009100621092303210a2304210b2300210c0b2009200a84200b200c8484504504400c030b024020042005200620071007210d2300210e2301210f230221100b200d200e84200f20108484504504400c030b02402004200520062007100821112300211223012113230221140b2011201284201320148484504504400c010b0b02402004200520062007100521152300211623012117230221180b201521042016210520172106201821070c000b0b200420052006200710100b0b6701077e0240200342017c2108200842007c2107200242007c210920092008200354200720085472ad7c2106200142007c210a200a2009200254200620095472ad7c2105200042007c200a2001542005200a5472ad7c21040b20052400200624012007240220040b2401047e0240420042008442002000848450ad21040b20022400200324012004240220010b2f01047e02402000420051200142005120024200512003420251717171ad21070b20052400200624012007240220040b2f01047e02402000420051200142005120024200512003420451717171ad21070b20052400200624012007240220040bab0104017e017f017e047f02404100210542002106417f210702402007200020065220002006541b21082008410046044002402007200120065220012006541b21092009410046044002402007200220065220022006541b210a200a41004604402003420a54210505200a41014604404100210505410121050b0b0b05200941014604404100210505410121050b0b0b05200841014604404100210505410121050b0b0b2005ad21040b20040b2901017f024042004200420084420084520440000b42004220422088520440000b4220a721000b20000b2f02017f017e02404200210120012001200184200184520440000b20012001422088520440000b2001a721000b20000b1f01017f024020004108744180fe0371200041087641ff01717221010b20010b1e01027f02402000100c411074210220022000411076100c7221010b20010b2201027e02402000a7100dad422086210220022000422088a7100dad8421010b20010be60105047e017f017e087f047e0240100221044200210520052005200584200584520440000b20052005422088520440000b2005a72106100b2107100a21082007417f20086b4b04404100410010010b200420076b2109200720044b0440410021090b4100210a2009200a4b044020062007200910030b200820094b0440200820096b210b200620096a210c200a210d02400340200d200b49450d010240200c200d6a200a3a00000b200d41016a210d0c000b0b0b02401011210e2300210f23012110230221110b200e2100200f210120102102201121030b20012400200224012003240220000b7801027e02404200a7100dad422086210420044200422088a7100dad84210541002005370000410041086a2005370000410041106a2005370000410041186a200537000041202000100e370000412041086a2001100e370000412041106a2002100e370000412041186a2003100e3700004100412010000b0b4201047e02404100290000100e2100410041086a290000100e2101410041106a290000100e2102410041186a290000100e21030b20012400200224012003240220000b Text representation: (module @@ -181,9 +191,10 @@ Text representation: (global $global_ (mut i64) (i64.const 0)) (global $global__1 (mut i64) (i64.const 0)) (global $global__2 (mut i64) (i64.const 0)) + (global $global__6 (mut i32) (i32.const 0)) + (global $global__7 (mut i32) (i32.const 0)) (func $main - (local $_1 i64) (local $x i64) (local $x_1 i64) (local $x_2 i64) @@ -192,8 +203,9 @@ Text representation: (local $x_5 i64) (local $x_6 i64) (local $x_7 i64) + (local $_1 i32) (local $_2 i64) - (local $_3 i32) + (local $_3 i64) (local $_4 i64) (local $_5 i64) (local $_6 i64) @@ -204,16 +216,13 @@ Text representation: (local $_11 i64) (local $_12 i64) (local $_13 i64) - (local $_14 i64) - (local $_15 i64) (local $x_8 i64) (local $x_9 i64) (local $x_10 i64) (local $x_11 i64) (block $label_ - (local.set $_1 (i64.const 0)) (block - (local.set $x (call $calldataload (local.get $_1) (local.get $_1) (local.get $_1) (local.get $_1))) + (local.set $x (call $calldataload)) (local.set $x_1 (global.get $global_)) (local.set $x_2 (global.get $global__1)) (local.set $x_3 (global.get $global__2)) @@ -223,46 +232,45 @@ Text representation: (local.set $x_5 (local.get $x_1)) (local.set $x_6 (local.get $x_2)) (local.set $x_7 (local.get $x_3)) - (local.set $_2 (i64.const 1)) - (local.set $_3 (i32.eqz (i32.eqz (i64.eqz (i64.or (i64.or (local.get $_1) (local.get $_1)) (i64.or (local.get $_1) (local.get $_2))))))) + (local.set $_1 (i32.eqz (i32.eqz (i64.eqz (i64.or (i64.or (i64.const 0) (i64.const 0)) (i64.or (i64.const 0) (i64.const 1))))))) (block $label__3 (loop $label__5 - (br_if $label__3 (i32.eqz (i32.eqz (local.get $_3)))) + (br_if $label__3 (i32.eqz (i32.eqz (local.get $_1)))) (block $label__4 (block - (local.set $_4 (call $iszero_887 (local.get $_1) (local.get $_1) (local.get $_1) (call $lt (local.get $x_4) (local.get $x_5) (local.get $x_6) (local.get $x_7) (local.get $_1) (local.get $_1) (local.get $_1) (i64.const 10)))) + (local.set $_2 (call $iszero_1300_2121 (call $lt (local.get $x_4) (local.get $x_5) (local.get $x_6) (local.get $x_7)))) + (local.set $_3 (global.get $global__6)) + (local.set $_4 (global.get $global__7)) (local.set $_5 (global.get $global_)) - (local.set $_6 (global.get $global__1)) - (local.set $_7 (global.get $global__2)) ) - (if (i32.eqz (i64.eqz (i64.or (i64.or (local.get $_4) (local.get $_5)) (i64.or (local.get $_6) (local.get $_7))))) (then + (if (i32.eqz (i64.eqz (i64.or (i64.or (local.get $_2) (local.get $_3)) (i64.or (local.get $_4) (local.get $_5))))) (then (br $label__3) )) (block - (local.set $_8 (call $eq_888 (local.get $x_4) (local.get $x_5) (local.get $x_6) (local.get $x_7) (local.get $_1) (local.get $_1) (local.get $_1) (i64.const 2))) - (local.set $_9 (global.get $global_)) - (local.set $_10 (global.get $global__1)) - (local.set $_11 (global.get $global__2)) + (local.set $_6 (call $eq_740_2122 (local.get $x_4) (local.get $x_5) (local.get $x_6) (local.get $x_7))) + (local.set $_7 (global.get $global_)) + (local.set $_8 (global.get $global__1)) + (local.set $_9 (global.get $global__2)) ) - (if (i32.eqz (i64.eqz (i64.or (i64.or (local.get $_8) (local.get $_9)) (i64.or (local.get $_10) (local.get $_11))))) (then + (if (i32.eqz (i64.eqz (i64.or (i64.or (local.get $_6) (local.get $_7)) (i64.or (local.get $_8) (local.get $_9))))) (then (br $label__3) )) (block - (local.set $_12 (call $eq_888 (local.get $x_4) (local.get $x_5) (local.get $x_6) (local.get $x_7) (local.get $_1) (local.get $_1) (local.get $_1) (i64.const 4))) - (local.set $_13 (global.get $global_)) - (local.set $_14 (global.get $global__1)) - (local.set $_15 (global.get $global__2)) + (local.set $_10 (call $eq_741_2123 (local.get $x_4) (local.get $x_5) (local.get $x_6) (local.get $x_7))) + (local.set $_11 (global.get $global_)) + (local.set $_12 (global.get $global__1)) + (local.set $_13 (global.get $global__2)) ) - (if (i32.eqz (i64.eqz (i64.or (i64.or (local.get $_12) (local.get $_13)) (i64.or (local.get $_14) (local.get $_15))))) (then + (if (i32.eqz (i64.eqz (i64.or (i64.or (local.get $_10) (local.get $_11)) (i64.or (local.get $_12) (local.get $_13))))) (then (br $label__4) )) ) (block - (local.set $x_8 (call $add (local.get $x_4) (local.get $x_5) (local.get $x_6) (local.get $x_7) (local.get $_1) (local.get $_1) (local.get $_1) (local.get $_2))) + (local.set $x_8 (call $add (local.get $x_4) (local.get $x_5) (local.get $x_6) (local.get $x_7))) (local.set $x_9 (global.get $global_)) (local.set $x_10 (global.get $global__1)) (local.set $x_11 (global.get $global__2)) @@ -276,90 +284,31 @@ Text representation: ) ) - (call $sstore (local.get $_1) (local.get $_1) (local.get $_1) (local.get $_1) (local.get $x_4) (local.get $x_5) (local.get $x_6) (local.get $x_7)) + (call $sstore (local.get $x_4) (local.get $x_5) (local.get $x_6) (local.get $x_7)) ) ) -(func $add_carry - (param $x i64) - (param $y i64) - (param $c i64) - (result i64) - (local $r i64) - (local $r_c i64) - (local $t i64) - (block $label__6 - (local.set $t (i64.add (local.get $x) (local.get $y))) - (local.set $r (i64.add (local.get $t) (local.get $c))) - (local.set $r_c (i64.extend_i32_u (i32.or (i64.lt_u (local.get $t) (local.get $x)) (i64.lt_u (local.get $r) (local.get $t))))) - - ) - (global.set $global_ (local.get $r_c)) - (local.get $r) -) - (func $add (param $x1 i64) (param $x2 i64) (param $x3 i64) (param $x4 i64) - (param $y1 i64) - (param $y2 i64) - (param $y3 i64) - (param $y4 i64) (result i64) (local $r1 i64) (local $r2 i64) (local $r3 i64) (local $r4 i64) (local $t i64) - (local $r3_1 i64) - (local $carry i64) - (local $r2_1 i64) - (local $carry_1 i64) - (local $r1_1 i64) - (local $carry_2 i64) - (block $label__7 - (local.set $t (i64.add (local.get $x4) (local.get $y4))) - (local.set $r4 (i64.add (local.get $t) (i64.const 0))) - (block - (local.set $r3_1 (call $add_carry (local.get $x3) (local.get $y3) (i64.extend_i32_u (i32.or (i64.lt_u (local.get $t) (local.get $x4)) (i64.lt_u (local.get $r4) (local.get $t)))))) - (local.set $carry (global.get $global_)) - - ) - (local.set $r3 (local.get $r3_1)) - (block - (local.set $r2_1 (call $add_carry (local.get $x2) (local.get $y2) (local.get $carry))) - (local.set $carry_1 (global.get $global_)) - - ) - (local.set $r2 (local.get $r2_1)) - (block - (local.set $r1_1 (call $add_carry (local.get $x1) (local.get $y1) (local.get $carry_1))) - (local.set $carry_2 (global.get $global_)) - - ) - (local.set $r1 (local.get $r1_1)) - - ) - (global.set $global_ (local.get $r2)) - (global.set $global__1 (local.get $r3)) - (global.set $global__2 (local.get $r4)) - (local.get $r1) -) - -(func $iszero_887 - (param $x1 i64) - (param $x2 i64) - (param $x3 i64) - (param $x4 i64) - (result i64) - (local $r1 i64) - (local $r2 i64) - (local $r3 i64) - (local $r4 i64) + (local $t_1 i64) + (local $t_2 i64) (block $label__8 - (local.set $r4 (i64.extend_i32_u (i64.eqz (i64.or (i64.or (local.get $x1) (local.get $x2)) (i64.or (local.get $x3) (local.get $x4)))))) + (local.set $t (i64.add (local.get $x4) (i64.const 1))) + (local.set $r4 (i64.add (local.get $t) (i64.const 0))) + (local.set $t_1 (i64.add (local.get $x3) (i64.const 0))) + (local.set $r3 (i64.add (local.get $t_1) (i64.extend_i32_u (i32.or (i64.lt_u (local.get $t) (local.get $x4)) (i64.lt_u (local.get $r4) (local.get $t)))))) + (local.set $t_2 (i64.add (local.get $x2) (i64.const 0))) + (local.set $r2 (i64.add (local.get $t_2) (i64.extend_i32_u (i32.or (i64.lt_u (local.get $t_1) (local.get $x3)) (i64.lt_u (local.get $r3) (local.get $t_1)))))) + (local.set $r1 (i64.add (i64.add (local.get $x1) (i64.const 0)) (i64.extend_i32_u (i32.or (i64.lt_u (local.get $t_2) (local.get $x2)) (i64.lt_u (local.get $r2) (local.get $t_2)))))) ) (global.set $global_ (local.get $r2)) @@ -368,22 +317,55 @@ Text representation: (local.get $r1) ) -(func $eq_888 - (param $x1 i64) - (param $x2 i64) - (param $x3 i64) +(func $iszero_1300_2121 (param $x4 i64) - (param $y1 i64) - (param $y2 i64) - (param $y3 i64) - (param $y4 i64) (result i64) (local $r1 i64) (local $r2 i64) (local $r3 i64) (local $r4 i64) (block $label__9 - (local.set $r4 (i64.extend_i32_u (i32.and (i64.eq (local.get $x1) (local.get $y1)) (i32.and (i64.eq (local.get $x2) (local.get $y2)) (i32.and (i64.eq (local.get $x3) (local.get $y3)) (i64.eq (local.get $x4) (local.get $y4))))))) + (local.set $r4 (i64.extend_i32_u (i64.eqz (i64.or (i64.or (i64.const 0) (i64.const 0)) (i64.or (i64.const 0) (local.get $x4)))))) + + ) + (global.set $global_ (local.get $r2)) + (global.set $global__1 (local.get $r3)) + (global.set $global__2 (local.get $r4)) + (local.get $r1) +) + +(func $eq_740_2122 + (param $x1 i64) + (param $x2 i64) + (param $x3 i64) + (param $x4 i64) + (result i64) + (local $r1 i64) + (local $r2 i64) + (local $r3 i64) + (local $r4 i64) + (block $label__10 + (local.set $r4 (i64.extend_i32_u (i32.and (i64.eq (local.get $x1) (i64.const 0)) (i32.and (i64.eq (local.get $x2) (i64.const 0)) (i32.and (i64.eq (local.get $x3) (i64.const 0)) (i64.eq (local.get $x4) (i64.const 2))))))) + + ) + (global.set $global_ (local.get $r2)) + (global.set $global__1 (local.get $r3)) + (global.set $global__2 (local.get $r4)) + (local.get $r1) +) + +(func $eq_741_2123 + (param $x1 i64) + (param $x2 i64) + (param $x3 i64) + (param $x4 i64) + (result i64) + (local $r1 i64) + (local $r2 i64) + (local $r3 i64) + (local $r4 i64) + (block $label__11 + (local.set $r4 (i64.extend_i32_u (i32.and (i64.eq (local.get $x1) (i64.const 0)) (i32.and (i64.eq (local.get $x2) (i64.const 0)) (i32.and (i64.eq (local.get $x3) (i64.const 0)) (i64.eq (local.get $x4) (i64.const 4))))))) ) (global.set $global_ (local.get $r2)) @@ -397,32 +379,30 @@ Text representation: (param $x2 i64) (param $x3 i64) (param $x4 i64) - (param $y1 i64) - (param $y2 i64) - (param $y3 i64) - (param $y4 i64) (result i64) (local $z4 i64) (local $z i32) - (local $_1 i32) + (local $_1 i64) + (local $_2 i32) (local $condition i32) - (local $condition_11 i32) - (local $condition_12 i32) - (block $label__10 + (local $condition_13 i32) + (local $condition_14 i32) + (block $label__12 (local.set $z (i32.const 0)) - (local.set $_1 (i32.const 4294967295)) + (local.set $_1 (i64.const 0)) + (local.set $_2 (i32.const 4294967295)) (block - (local.set $condition (select (local.get $_1) (i64.ne (local.get $x1) (local.get $y1)) (i64.lt_u (local.get $x1) (local.get $y1)))) + (local.set $condition (select (local.get $_2) (i64.ne (local.get $x1) (local.get $_1)) (i64.lt_u (local.get $x1) (local.get $_1)))) (if (i32.eq (local.get $condition) (i32.const 0)) (then (block - (local.set $condition_11 (select (local.get $_1) (i64.ne (local.get $x2) (local.get $y2)) (i64.lt_u (local.get $x2) (local.get $y2)))) - (if (i32.eq (local.get $condition_11) (i32.const 0)) (then + (local.set $condition_13 (select (local.get $_2) (i64.ne (local.get $x2) (local.get $_1)) (i64.lt_u (local.get $x2) (local.get $_1)))) + (if (i32.eq (local.get $condition_13) (i32.const 0)) (then (block - (local.set $condition_12 (select (local.get $_1) (i64.ne (local.get $x3) (local.get $y3)) (i64.lt_u (local.get $x3) (local.get $y3)))) - (if (i32.eq (local.get $condition_12) (i32.const 0)) (then - (local.set $z (i64.lt_u (local.get $x4) (local.get $y4))) + (local.set $condition_14 (select (local.get $_2) (i64.ne (local.get $x3) (local.get $_1)) (i64.lt_u (local.get $x3) (local.get $_1)))) + (if (i32.eq (local.get $condition_14) (i32.const 0)) (then + (local.set $z (i64.lt_u (local.get $x4) (i64.const 10))) )(else - (if (i32.eq (local.get $condition_12) (i32.const 1)) (then + (if (i32.eq (local.get $condition_14) (i32.const 1)) (then (local.set $z (i32.const 0)) )(else (local.set $z (i32.const 1)) @@ -431,7 +411,7 @@ Text representation: ) )(else - (if (i32.eq (local.get $condition_11) (i32.const 1)) (then + (if (i32.eq (local.get $condition_13) (i32.const 1)) (then (local.set $z (i32.const 0)) )(else (local.set $z (i32.const 1)) @@ -454,19 +434,31 @@ Text representation: (local.get $z4) ) -(func $u256_to_i32 - (param $x1 i64) - (param $x2 i64) - (param $x3 i64) - (param $x4 i64) +(func $u256_to_i32_744 (result i32) (local $v i32) - (block $label__13 - (if (i64.ne (i64.const 0) (i64.or (i64.or (local.get $x1) (local.get $x2)) (local.get $x3))) (then + (block $label__15 + (if (i64.ne (i64.const 0) (i64.or (i64.or (i64.const 0) (i64.const 0)) (i64.const 0))) (then (unreachable))) - (if (i64.ne (i64.const 0) (i64.shr_u (local.get $x4) (i64.const 32))) (then + (if (i64.ne (i64.const 0) (i64.shr_u (i64.const 32) (i64.const 32))) (then (unreachable))) - (local.set $v (i32.wrap_i64 (local.get $x4))) + (local.set $v (i32.wrap_i64 (i64.const 32))) + + ) + (local.get $v) +) + +(func $u256_to_i32 + (result i32) + (local $v i32) + (local $_1 i64) + (block $label__16 + (local.set $_1 (i64.const 0)) + (if (i64.ne (local.get $_1) (i64.or (i64.or (local.get $_1) (local.get $_1)) (local.get $_1))) (then + (unreachable))) + (if (i64.ne (local.get $_1) (i64.shr_u (local.get $_1) (i64.const 32))) (then + (unreachable))) + (local.set $v (i32.wrap_i64 (local.get $_1))) ) (local.get $v) @@ -476,7 +468,7 @@ Text representation: (param $x i32) (result i32) (local $y i32) - (block $label__14 + (block $label__17 (local.set $y (i32.or (i32.and (i32.shl (local.get $x) (i32.const 8)) (i32.const 65280)) (i32.and (i32.shr_u (local.get $x) (i32.const 8)) (i32.const 255)))) ) @@ -488,7 +480,7 @@ Text representation: (result i32) (local $y i32) (local $hi i32) - (block $label__15 + (block $label__18 (local.set $hi (i32.shl (call $bswap16 (local.get $x)) (i32.const 16))) (local.set $y (i32.or (local.get $hi) (call $bswap16 (i32.shr_u (local.get $x) (i32.const 16))))) @@ -501,7 +493,7 @@ Text representation: (result i64) (local $y i64) (local $hi i64) - (block $label__16 + (block $label__19 (local.set $hi (i64.shl (i64.extend_i32_u (call $bswap32 (i32.wrap_i64 (local.get $x)))) (i64.const 32))) (local.set $y (i64.or (local.get $hi) (i64.extend_i32_u (call $bswap32 (i32.wrap_i64 (i64.shr_u (local.get $x) (i64.const 32))))))) @@ -510,10 +502,6 @@ Text representation: ) (func $calldataload - (param $x1 i64) - (param $x2 i64) - (param $x3 i64) - (param $x4 i64) (result i64) (local $z1 i64) (local $z2 i64) @@ -521,7 +509,7 @@ Text representation: (local $z4 i64) (local $cds i32) (local $_1 i64) - (local $destination i32) + (local $v i32) (local $offset i32) (local $requested_size i32) (local $available_size i32) @@ -533,12 +521,16 @@ Text representation: (local $z2_1 i64) (local $z3_1 i64) (local $z4_1 i64) - (block $label__17 + (block $label__20 (local.set $cds (call $eth.getCallDataSize)) (local.set $_1 (i64.const 0)) - (local.set $destination (call $u256_to_i32 (local.get $_1) (local.get $_1) (local.get $_1) (local.get $_1))) - (local.set $offset (call $u256_to_i32 (local.get $x1) (local.get $x2) (local.get $x3) (local.get $x4))) - (local.set $requested_size (call $u256_to_i32 (local.get $_1) (local.get $_1) (local.get $_1) (i64.const 32))) + (if (i64.ne (local.get $_1) (i64.or (i64.or (local.get $_1) (local.get $_1)) (local.get $_1))) (then + (unreachable))) + (if (i64.ne (local.get $_1) (i64.shr_u (local.get $_1) (i64.const 32))) (then + (unreachable))) + (local.set $v (i32.wrap_i64 (local.get $_1))) + (local.set $offset (call $u256_to_i32)) + (local.set $requested_size (call $u256_to_i32_744)) (if (i32.gt_u (local.get $offset) (i32.sub (i32.const 4294967295) (local.get $requested_size))) (then (call $eth.revert (i32.const 0) (i32.const 0)))) (local.set $available_size (i32.sub (local.get $cds) (local.get $offset))) @@ -547,27 +539,30 @@ Text representation: )) (local.set $_2 (i32.const 0)) (if (i32.gt_u (local.get $available_size) (local.get $_2)) (then - (call $eth.callDataCopy (local.get $destination) (local.get $offset) (local.get $available_size)))) + (call $eth.callDataCopy (local.get $v) (local.get $offset) (local.get $available_size)))) (if (i32.gt_u (local.get $requested_size) (local.get $available_size)) (then (local.set $_3 (i32.sub (local.get $requested_size) (local.get $available_size))) - (local.set $_4 (i32.add (local.get $destination) (local.get $available_size))) + (local.set $_4 (i32.add (local.get $v) (local.get $available_size))) (local.set $i (local.get $_2)) - (block $label__18 - (loop $label__20 - (br_if $label__18 (i32.eqz (i32.lt_u (local.get $i) (local.get $_3)))) - (block $label__19 + (block $label__21 + (loop $label__23 + (br_if $label__21 (i32.eqz (i32.lt_u (local.get $i) (local.get $_3)))) + (block $label__22 (i32.store8 (i32.add (local.get $_4) (local.get $i)) (local.get $_2)) ) (local.set $i (i32.add (local.get $i) (i32.const 1))) - (br $label__20) + (br $label__23) ) ) )) - (local.set $z1_1 (call $bswap64 (i64.load (local.get $_2)))) - (local.set $z2_1 (call $bswap64 (i64.load (i32.add (local.get $_2) (i32.const 8))))) - (local.set $z3_1 (call $bswap64 (i64.load (i32.add (local.get $_2) (i32.const 16))))) - (local.set $z4_1 (call $bswap64 (i64.load (i32.add (local.get $_2) (i32.const 24))))) + (block + (local.set $z1_1 (call $mload_internal)) + (local.set $z2_1 (global.get $global_)) + (local.set $z3_1 (global.get $global__1)) + (local.set $z4_1 (global.get $global__2)) + + ) (local.set $z1 (local.get $z1_1)) (local.set $z2 (local.get $z2_1)) (local.set $z3 (local.get $z3_1)) @@ -581,33 +576,44 @@ Text representation: ) (func $sstore - (param $x1 i64) - (param $x2 i64) - (param $x3 i64) - (param $x4 i64) (param $y1 i64) (param $y2 i64) (param $y3 i64) (param $y4 i64) - (block $label__21 - (call $mstore_internal (i32.const 0) (local.get $x1) (local.get $x2) (local.get $x3) (local.get $x4)) - (call $mstore_internal (i32.const 32) (local.get $y1) (local.get $y2) (local.get $y3) (local.get $y4)) + (local $hi i64) + (local $y i64) + (block $label__24 + (local.set $hi (i64.shl (i64.extend_i32_u (call $bswap32 (i32.wrap_i64 (i64.const 0)))) (i64.const 32))) + (local.set $y (i64.or (local.get $hi) (i64.extend_i32_u (call $bswap32 (i32.wrap_i64 (i64.shr_u (i64.const 0) (i64.const 32))))))) + (i64.store (i32.const 0) (local.get $y)) + (i64.store (i32.add (i32.const 0) (i32.const 8)) (local.get $y)) + (i64.store (i32.add (i32.const 0) (i32.const 16)) (local.get $y)) + (i64.store (i32.add (i32.const 0) (i32.const 24)) (local.get $y)) + (i64.store (i32.const 32) (call $bswap64 (local.get $y1))) + (i64.store (i32.add (i32.const 32) (i32.const 8)) (call $bswap64 (local.get $y2))) + (i64.store (i32.add (i32.const 32) (i32.const 16)) (call $bswap64 (local.get $y3))) + (i64.store (i32.add (i32.const 32) (i32.const 24)) (call $bswap64 (local.get $y4))) (call $eth.storageStore (i32.const 0) (i32.const 32)) ) ) -(func $mstore_internal - (param $pos i32) - (param $y1 i64) - (param $y2 i64) - (param $y3 i64) - (param $y4 i64) - (block $label__22 - (i64.store (local.get $pos) (call $bswap64 (local.get $y1))) - (i64.store (i32.add (local.get $pos) (i32.const 8)) (call $bswap64 (local.get $y2))) - (i64.store (i32.add (local.get $pos) (i32.const 16)) (call $bswap64 (local.get $y3))) - (i64.store (i32.add (local.get $pos) (i32.const 24)) (call $bswap64 (local.get $y4))) +(func $mload_internal + (result i64) + (local $z1 i64) + (local $z2 i64) + (local $z3 i64) + (local $z4 i64) + (block $label__25 + (local.set $z1 (call $bswap64 (i64.load (i32.const 0)))) + (local.set $z2 (call $bswap64 (i64.load (i32.add (i32.const 0) (i32.const 8))))) + (local.set $z3 (call $bswap64 (i64.load (i32.add (i32.const 0) (i32.const 16))))) + (local.set $z4 (call $bswap64 (i64.load (i32.add (i32.const 0) (i32.const 24))))) + ) + (global.set $global_ (local.get $z2)) + (global.set $global__1 (local.get $z3)) + (global.set $global__2 (local.get $z4)) + (local.get $z1) ) ) diff --git a/test/cmdlineTests/ir_compiler_subobjects/output b/test/cmdlineTests/ir_compiler_subobjects/output index ee9ae8138..79f6fcae4 100644 --- a/test/cmdlineTests/ir_compiler_subobjects/output +++ b/test/cmdlineTests/ir_compiler_subobjects/output @@ -64,17 +64,16 @@ object "D_16" { returndatacopy(_1, _1, returndatasize()) revert(_1, returndatasize()) } - return(allocate_memory(_1), _1) + return(allocate_memory(), _1) } } revert(0, 0) } - function allocate_memory(size) -> memPtr + function allocate_memory() -> memPtr { memPtr := mload(64) - let newFreePtr := add(memPtr, and(add(size, 31), not(31))) - if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr)) { panic_error_0x41() } - mstore(64, newFreePtr) + if gt(memPtr, 0xffffffffffffffff) { panic_error_0x41() } + mstore(64, memPtr) } function panic_error_0x41() { diff --git a/test/cmdlineTests/name_simplifier/output b/test/cmdlineTests/name_simplifier/output index a26c82966..ad1cc3cde 100644 --- a/test/cmdlineTests/name_simplifier/output +++ b/test/cmdlineTests/name_simplifier/output @@ -45,14 +45,14 @@ object "C_59" { for { } lt(i, _4) { i := add(i, 1) } { if slt(sub(calldatasize(), src), _2) { revert(_1, _1) } - let value := allocate_memory(_2) + let value := allocate_memory_1246() mstore(value, calldataload(src)) mstore(dst, value) dst := add(dst, _2) src := add(src, _2) } let ret, ret_1 := fun_sumArray(dst_1) - let memPos := allocate_memory(_1) + let memPos := allocate_memory_1247() return(memPos, sub(abi_encode_uint256_string(memPos, ret, ret_1), memPos)) } } @@ -76,6 +76,19 @@ object "C_59" { } tail := add(add(headStart, and(add(length, 31), not(31))), 96) } + function allocate_memory_1246() -> memPtr + { + memPtr := mload(64) + let newFreePtr := add(memPtr, 32) + if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr)) { panic_error_0x41() } + mstore(64, newFreePtr) + } + function allocate_memory_1247() -> memPtr + { + memPtr := mload(64) + if gt(memPtr, 0xffffffffffffffff) { panic_error_0x41() } + mstore(64, memPtr) + } function allocate_memory(size) -> memPtr { memPtr := mload(64) @@ -85,7 +98,10 @@ object "C_59" { } function copy_literal_to_memory_64902fd228f7ef267f3b474dd6ef84bae434cf5546eee948e7ca26df3eda1927() -> memPtr { - let memPtr_1 := allocate_memory(160) + let memPtr_1 := mload(64) + let newFreePtr := add(memPtr_1, 160) + if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr_1)) { panic_error_0x41() } + mstore(64, newFreePtr) mstore(memPtr_1, 100) memPtr := memPtr_1 mstore(add(memPtr_1, 0x20), "longstringlongstringlongstringlo") @@ -101,7 +117,7 @@ object "C_59" { { if iszero(lt(var_mpos, mload(var_s_mpos))) { panic_error_0x32() } let _1 := mload(mload(add(add(var_s_mpos, shl(5, var_mpos)), 32))) - let _2, _3 := storage_array_index_access_struct_S(var_mpos, var_mpos) + let _2, _3 := storage_array_index_access_struct_S_1254() sstore(_2, _1) if iszero(lt(0x01, mload(var_s_mpos))) { panic_error_0x32() } let _4 := mload(mload(add(var_s_mpos, 64))) @@ -111,7 +127,7 @@ object "C_59" { let shiftBits := shl(3, var_mpos) let mask := shl(shiftBits, not(0)) sstore(slot, or(and(_5, not(mask)), and(shl(shiftBits, _4), mask))) - let _6, _7 := storage_array_index_access_struct_S(0x02, var_mpos) + let _6, _7 := storage_array_index_access_struct_S() var := extract_from_storage_value_dynamict_uint256(sload(_6), _7) var_mpos := copy_literal_to_memory_64902fd228f7ef267f3b474dd6ef84bae434cf5546eee948e7ca26df3eda1927() } @@ -127,10 +143,16 @@ object "C_59" { mstore(4, 0x41) revert(0, 0x24) } - function storage_array_index_access_struct_S(array, index) -> slot, offset + function storage_array_index_access_struct_S_1254() -> slot, offset { - if iszero(lt(index, 0x02)) { panic_error_0x32() } - slot := add(array, index) + if iszero(lt(slot, 0x02)) { panic_error_0x32() } + slot := add(slot, slot) + offset := offset + } + function storage_array_index_access_struct_S() -> slot, offset + { + if iszero(lt(slot, 0x02)) { panic_error_0x32() } + slot := add(0x02, slot) offset := offset } } diff --git a/test/cmdlineTests/optimizer_array_sload/output b/test/cmdlineTests/optimizer_array_sload/output index ecf8fdb4c..a4b9e8a60 100644 --- a/test/cmdlineTests/optimizer_array_sload/output +++ b/test/cmdlineTests/optimizer_array_sload/output @@ -40,7 +40,7 @@ object "Arraysum_34" { mstore(_1, _1) var_sum := checked_add_uint256(var_sum, sload(add(keccak256(_1, 0x20), var_i))) } - let memPos := allocate_memory(_1) + let memPos := allocate_memory() return(memPos, sub(abi_encode_uint256(memPos, var_sum), memPos)) } } @@ -51,17 +51,16 @@ object "Arraysum_34" { tail := add(headStart, 32) mstore(headStart, value0) } - function allocate_memory(size) -> memPtr + function allocate_memory() -> memPtr { memPtr := mload(64) - let newFreePtr := add(memPtr, and(add(size, 31), not(31))) - if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr)) + if gt(memPtr, 0xffffffffffffffff) { mstore(0, shl(224, 0x4e487b71)) mstore(4, 0x41) revert(0, 0x24) } - mstore(64, newFreePtr) + mstore(64, memPtr) } function checked_add_uint256(x, y) -> sum { diff --git a/test/cmdlineTests/standard_ewasm_requested/output.json b/test/cmdlineTests/standard_ewasm_requested/output.json index c7c994435..40e7ca65f 100644 --- a/test/cmdlineTests/standard_ewasm_requested/output.json +++ b/test/cmdlineTests/standard_ewasm_requested/output.json @@ -1,7 +1,7 @@ -{"contracts":{"A":{"C":{"ewasm":{"wasm":"0061736d01000000013f0960000060017e017e60047e7e7e7e017f60087e7e7e7e7e7e7e7e00600c7e7e7e7e7e7e7e7e7e7e7e7e0060017f0060017f017f60027f7f0060037f7f7f0002510408657468657265756d08636f6465436f7079000808657468657265756d06726576657274000708657468657265756d0c67657443616c6c56616c7565000508657468657265756d0666696e6973680007030a090002020606010403030503010001060100071102066d656d6f72790200046d61696e00040086030c435f335f6465706c6f7965640061736d0100000001160460000060047e7e7e7e017f60017f017f60027f7f0002130108657468657265756d067265766572740003030504000102020503010001060100071102066d656d6f72790200046d61696e00010a9f0204b30104017e027f037e037f02404200210020002000200042c00010022101200141c0006a210220022001490440000b2000a71004ad422086210320032000422088a71004ad84210420022004370000200241086a2004370000200241106a2004370000428001a71004ad4220862105200241186a2005428001422088a71004ad84370000200020002000200010022106200020002000200010022107200741c0006a210820082007490440000b2008200610000b0b2901017f024042002000200184200284520440000b42002003422088520440000b2003a721040b20040b1f01017f024020004108744180fe0371200041087641ff01717221010b20010b1e01027f02402000100341107421022002200041107610037221010b20010b0af00309dc0103017e027f057e02404200210020002000200042c00010052101200141c0006a210220022001490440000b20001009210320022003370000200241086a2003370000200241106a2003370000200241186a428001100937000041001002410029000010092104410041086a29000010092105410041106a2900001009210620042005842006410041186a290000100984845045044020002000200020002000200020002000100c0b42f9022107200020002000200020002000200042d3012000200020002007100a20002000200020002000200020002007100b0b0b2901017f024042002000200184200284520440000b42002003422088520440000b2003a721040b20040b2601027f0240200020012002200310052105200541c0006a210420042005490440000b0b20040b1f01017f024020004108744180fe0371200041087641ff01717221010b20010b1e01027f02402000100741107421022002200041107610077221010b20010b2201027e02402000a71008ad422086210220022000422088a71008ad8421010b20010b25000240200020012002200310062004200520062007100520082009200a200b100510000b0b1b000240200020012002200310062004200520062007100510030b0b1b000240200020012002200310062004200520062007100510010b0b","wast":"(module +{"contracts":{"A":{"C":{"ewasm":{"wasm":"0061736d0100000001330b6000006000017e6000017f60017e0060017e017e60017e017f60027e7e0060017f0060017f017f60027f7f0060037f7f7f0002510408657468657265756d08636f6465436f7079000a08657468657265756d06726576657274000908657468657265756d0c67657443616c6c56616c7565000708657468657265756d0666696e6973680009030d0c0002050208080101040603000503010001060100071102066d656d6f72790200046d61696e00040092030c435f335f6465706c6f7965640061736d010000000112046000006000017f60017f017f60027f7f0002130108657468657265756d06726576657274000303060500010102020503010001060100071102066d656d6f72790200046d61696e00010aae02059d0103017e027f037e02404200210020002000200084200084520440000b200042c000422088520440000b42c000a72101200141c0006a210220022001490440000b2000a71005ad422086210320032000422088a71005ad84210420022004370000200241086a2004370000200241106a2004370000428001a71005ad4220862105200241186a2005428001422088a71005ad843700001003100210000b0b2f02017f017e02404200210120012001200184200184520440000b20012001422088520440000b2001a721000b20000b1e01027f024010022101200141c0006a210020002001490440000b0b20000b1f01017f024020004108744180fe0371200041087641ff01717221010b20010b1e01027f02402000100441107421022002200041107610047221010b20010b0aca040c960102027f057e024010052100200041c0006a210120012000490440000b100a210220012002370000200141086a2002370000200141106a2002370000200141186a100b370000410010024100290000100c2103410041086a290000100c2104410041106a290000100c210520032004842005410041186a290000100c848450450440100f0b428503210642ca012006100d2006100e0b0b2b01017f024042004200420084420084520440000b420042c000422088520440000b42c000a721000b20000b2901017f024042004200420084420084520440000b42002000422088520440000b2000a721010b20010b2f02017f017e02404200210120012001200184200184520440000b20012001422088520440000b2001a721000b20000b1f01017f024020004108744180fe0371200041087641ff01717221010b20010b1e01027f02402000100841107421022002200041107610087221010b20010b2201027e02404200a71009ad422086210120014200422088a71009ad8421000b20000b2401027e0240428001a71009ad42208621012001428001422088a71009ad8421000b20000b2201027e02402000a71009ad422086210220022000422088a71009ad8421010b20010b3001047f024020011006210220001006210310072104200441c0006a210520052004490440000b20052003200210000b0b2801037f024020001006210110072102200241c0006a210320032002490440000b2003200110030b0b2601037f02401007210010072101200141c0006a210220022001490440000b2002200010010b0b","wast":"(module ;; custom section for sub-module - ;; The Keccak-256 hash of the text representation of \"C_3_deployed\": 380167268971b84f9fd4e61f1659da4fd304bd6e30ec2dd33d412f3c8203ced7 - ;; (@custom \"C_3_deployed\" \"0061736d0100000001160460000060047e7e7e7e017f60017f017f60027f7f0002130108657468657265756d067265766572740003030504000102020503010001060100071102066d656d6f72790200046d61696e00010a9f0204b30104017e027f037e037f02404200210020002000200042c00010022101200141c0006a210220022001490440000b2000a71004ad422086210320032000422088a71004ad84210420022004370000200241086a2004370000200241106a2004370000428001a71004ad4220862105200241186a2005428001422088a71004ad84370000200020002000200010022106200020002000200010022107200741c0006a210820082007490440000b2008200610000b0b2901017f024042002000200184200284520440000b42002003422088520440000b2003a721040b20040b1f01017f024020004108744180fe0371200041087641ff01717221010b20010b1e01027f02402000100341107421022002200041107610037221010b20010b\") + ;; The Keccak-256 hash of the text representation of \"C_3_deployed\": 1c21519afc0397d3ba45d99eb2354c3d74191cd82bffab348d52efabddb63f6a + ;; (@custom \"C_3_deployed\" \"0061736d010000000112046000006000017f60017f017f60027f7f0002130108657468657265756d06726576657274000303060500010102020503010001060100071102066d656d6f72790200046d61696e00010aae02059d0103017e027f037e02404200210020002000200084200084520440000b200042c000422088520440000b42c000a72101200141c0006a210220022001490440000b2000a71005ad422086210320032000422088a71005ad84210420022004370000200241086a2004370000200241106a2004370000428001a71005ad4220862105200241186a2005428001422088a71005ad843700001003100210000b0b2f02017f017e02404200210120012001200184200184520440000b20012001422088520440000b2001a721000b20000b1e01027f024010022101200141c0006a210020002001490440000b0b20000b1f01017f024020004108744180fe0371200041087641ff01717221010b20010b1e01027f02402000100441107421022002200041107610047221010b20010b\") (import \"ethereum\" \"codeCopy\" (func $eth.codeCopy (param i32 i32 i32))) (import \"ethereum\" \"revert\" (func $eth.revert (param i32 i32))) (import \"ethereum\" \"getCallValue\" (func $eth.getCallValue (param i32))) @@ -10,46 +10,55 @@ (export \"main\" (func $main)) (func $main - (local $_1 i64) (local $p i32) (local $r i32) - (local $_2 i64) + (local $_1 i64) (local $z1 i64) (local $z2 i64) (local $z3 i64) - (local $_3 i64) + (local $_2 i64) (block $label_ - (local.set $_1 (i64.const 0)) - (local.set $p (call $u256_to_i32 (local.get $_1) (local.get $_1) (local.get $_1) (i64.const 64))) + (local.set $p (call $u256_to_i32_685)) (local.set $r (i32.add (local.get $p) (i32.const 64))) (if (i32.lt_u (local.get $r) (local.get $p)) (then (unreachable))) - (local.set $_2 (call $bswap64 (local.get $_1))) - (i64.store (local.get $r) (local.get $_2)) - (i64.store (i32.add (local.get $r) (i32.const 8)) (local.get $_2)) - (i64.store (i32.add (local.get $r) (i32.const 16)) (local.get $_2)) - (i64.store (i32.add (local.get $r) (i32.const 24)) (call $bswap64 (i64.const 128))) + (local.set $_1 (call $bswap64_388)) + (i64.store (local.get $r) (local.get $_1)) + (i64.store (i32.add (local.get $r) (i32.const 8)) (local.get $_1)) + (i64.store (i32.add (local.get $r) (i32.const 16)) (local.get $_1)) + (i64.store (i32.add (local.get $r) (i32.const 24)) (call $bswap64_389)) (call $eth.getCallValue (i32.const 0)) (local.set $z1 (call $bswap64 (i64.load (i32.const 0)))) (local.set $z2 (call $bswap64 (i64.load (i32.add (i32.const 0) (i32.const 8))))) (local.set $z3 (call $bswap64 (i64.load (i32.add (i32.const 0) (i32.const 16))))) (if (i32.eqz (i64.eqz (i64.or (i64.or (local.get $z1) (local.get $z2)) (i64.or (local.get $z3) (call $bswap64 (i64.load (i32.add (i32.const 0) (i32.const 24)))))))) (then - (call $revert (local.get $_1) (local.get $_1) (local.get $_1) (local.get $_1) (local.get $_1) (local.get $_1) (local.get $_1) (local.get $_1)))) - (local.set $_3 (datasize \"C_3_deployed\")) - (call $codecopy (local.get $_1) (local.get $_1) (local.get $_1) (local.get $_1) (local.get $_1) (local.get $_1) (local.get $_1) (dataoffset \"C_3_deployed\") (local.get $_1) (local.get $_1) (local.get $_1) (local.get $_3)) - (call $return (local.get $_1) (local.get $_1) (local.get $_1) (local.get $_1) (local.get $_1) (local.get $_1) (local.get $_1) (local.get $_3)) + (call $revert))) + (local.set $_2 (datasize \"C_3_deployed\")) + (call $codecopy (dataoffset \"C_3_deployed\") (local.get $_2)) + (call $return (local.get $_2)) ) ) -(func $u256_to_i32 - (param $x1 i64) - (param $x2 i64) - (param $x3 i64) - (param $x4 i64) +(func $u256_to_i32_685 (result i32) (local $v i32) (block $label__1 - (if (i64.ne (i64.const 0) (i64.or (i64.or (local.get $x1) (local.get $x2)) (local.get $x3))) (then + (if (i64.ne (i64.const 0) (i64.or (i64.or (i64.const 0) (i64.const 0)) (i64.const 0))) (then + (unreachable))) + (if (i64.ne (i64.const 0) (i64.shr_u (i64.const 64) (i64.const 32))) (then + (unreachable))) + (local.set $v (i32.wrap_i64 (i64.const 64))) + + ) + (local.get $v) +) + +(func $u256_to_i32_687 + (param $x4 i64) + (result i32) + (local $v i32) + (block $label__2 + (if (i64.ne (i64.const 0) (i64.or (i64.or (i64.const 0) (i64.const 0)) (i64.const 0))) (then (unreachable))) (if (i64.ne (i64.const 0) (i64.shr_u (local.get $x4) (i64.const 32))) (then (unreachable))) @@ -59,29 +68,27 @@ (local.get $v) ) -(func $to_internal_i32ptr - (param $x1 i64) - (param $x2 i64) - (param $x3 i64) - (param $x4 i64) +(func $u256_to_i32 (result i32) - (local $r i32) - (local $p i32) - (block $label__2 - (local.set $p (call $u256_to_i32 (local.get $x1) (local.get $x2) (local.get $x3) (local.get $x4))) - (local.set $r (i32.add (local.get $p) (i32.const 64))) - (if (i32.lt_u (local.get $r) (local.get $p)) (then + (local $v i32) + (local $_1 i64) + (block $label__3 + (local.set $_1 (i64.const 0)) + (if (i64.ne (local.get $_1) (i64.or (i64.or (local.get $_1) (local.get $_1)) (local.get $_1))) (then (unreachable))) + (if (i64.ne (local.get $_1) (i64.shr_u (local.get $_1) (i64.const 32))) (then + (unreachable))) + (local.set $v (i32.wrap_i64 (local.get $_1))) ) - (local.get $r) + (local.get $v) ) (func $bswap16 (param $x i32) (result i32) (local $y i32) - (block $label__3 + (block $label__4 (local.set $y (i32.or (i32.and (i32.shl (local.get $x) (i32.const 8)) (i32.const 65280)) (i32.and (i32.shr_u (local.get $x) (i32.const 8)) (i32.const 255)))) ) @@ -93,7 +100,7 @@ (result i32) (local $y i32) (local $hi i32) - (block $label__4 + (block $label__5 (local.set $hi (i32.shl (call $bswap16 (local.get $x)) (i32.const 16))) (local.set $y (i32.or (local.get $hi) (call $bswap16 (i32.shr_u (local.get $x) (i32.const 16))))) @@ -101,12 +108,36 @@ (local.get $y) ) +(func $bswap64_388 + (result i64) + (local $y i64) + (local $hi i64) + (block $label__6 + (local.set $hi (i64.shl (i64.extend_i32_u (call $bswap32 (i32.wrap_i64 (i64.const 0)))) (i64.const 32))) + (local.set $y (i64.or (local.get $hi) (i64.extend_i32_u (call $bswap32 (i32.wrap_i64 (i64.shr_u (i64.const 0) (i64.const 32))))))) + + ) + (local.get $y) +) + +(func $bswap64_389 + (result i64) + (local $y i64) + (local $hi i64) + (block $label__7 + (local.set $hi (i64.shl (i64.extend_i32_u (call $bswap32 (i32.wrap_i64 (i64.const 128)))) (i64.const 32))) + (local.set $y (i64.or (local.get $hi) (i64.extend_i32_u (call $bswap32 (i32.wrap_i64 (i64.shr_u (i64.const 128) (i64.const 32))))))) + + ) + (local.get $y) +) + (func $bswap64 (param $x i64) (result i64) (local $y i64) (local $hi i64) - (block $label__5 + (block $label__8 (local.set $hi (i64.shl (i64.extend_i32_u (call $bswap32 (i32.wrap_i64 (local.get $x)))) (i64.const 32))) (local.set $y (i64.or (local.get $hi) (i64.extend_i32_u (call $bswap32 (i32.wrap_i64 (i64.shr_u (local.get $x) (i64.const 32))))))) @@ -115,48 +146,49 @@ ) (func $codecopy - (param $x1 i64) - (param $x2 i64) - (param $x3 i64) - (param $x4 i64) - (param $y1 i64) - (param $y2 i64) - (param $y3 i64) (param $y4 i64) - (param $z1 i64) - (param $z2 i64) - (param $z3 i64) (param $z4 i64) - (block $label__6 - (call $eth.codeCopy (call $to_internal_i32ptr (local.get $x1) (local.get $x2) (local.get $x3) (local.get $x4)) (call $u256_to_i32 (local.get $y1) (local.get $y2) (local.get $y3) (local.get $y4)) (call $u256_to_i32 (local.get $z1) (local.get $z2) (local.get $z3) (local.get $z4))) + (local $_1 i32) + (local $_2 i32) + (local $p i32) + (local $r i32) + (block $label__9 + (local.set $_1 (call $u256_to_i32_687 (local.get $z4))) + (local.set $_2 (call $u256_to_i32_687 (local.get $y4))) + (local.set $p (call $u256_to_i32)) + (local.set $r (i32.add (local.get $p) (i32.const 64))) + (if (i32.lt_u (local.get $r) (local.get $p)) (then + (unreachable))) + (call $eth.codeCopy (local.get $r) (local.get $_2) (local.get $_1)) ) ) (func $return - (param $x1 i64) - (param $x2 i64) - (param $x3 i64) - (param $x4 i64) - (param $y1 i64) - (param $y2 i64) - (param $y3 i64) (param $y4 i64) - (block $label__7 - (call $eth.finish (call $to_internal_i32ptr (local.get $x1) (local.get $x2) (local.get $x3) (local.get $x4)) (call $u256_to_i32 (local.get $y1) (local.get $y2) (local.get $y3) (local.get $y4))) + (local $_1 i32) + (local $p i32) + (local $r i32) + (block $label__10 + (local.set $_1 (call $u256_to_i32_687 (local.get $y4))) + (local.set $p (call $u256_to_i32)) + (local.set $r (i32.add (local.get $p) (i32.const 64))) + (if (i32.lt_u (local.get $r) (local.get $p)) (then + (unreachable))) + (call $eth.finish (local.get $r) (local.get $_1)) ) ) (func $revert - (param $x1 i64) - (param $x2 i64) - (param $x3 i64) - (param $x4 i64) - (param $y1 i64) - (param $y2 i64) - (param $y3 i64) - (param $y4 i64) - (block $label__8 - (call $eth.revert (call $to_internal_i32ptr (local.get $x1) (local.get $x2) (local.get $x3) (local.get $x4)) (call $u256_to_i32 (local.get $y1) (local.get $y2) (local.get $y3) (local.get $y4))) + (local $_1 i32) + (local $p i32) + (local $r i32) + (block $label__11 + (local.set $_1 (call $u256_to_i32)) + (local.set $p (call $u256_to_i32)) + (local.set $r (i32.add (local.get $p) (i32.const 64))) + (if (i32.lt_u (local.get $r) (local.get $p)) (then + (unreachable))) + (call $eth.revert (local.get $r) (local.get $_1)) ) ) diff --git a/test/cmdlineTests/viair_subobjects/output b/test/cmdlineTests/viair_subobjects/output index 36019c4b8..3f7c6c294 100644 --- a/test/cmdlineTests/viair_subobjects/output +++ b/test/cmdlineTests/viair_subobjects/output @@ -35,9 +35,9 @@ object "C_3" { ======= viair_subobjects/input.sol:D ======= Binary: -608060405234156100105760006000fd5b61010d80610021600039806000f350fe6080604052600436101515610088576000803560e01c6326121ff0141561008657341561002a578081fd5b806003193601121561003a578081fd5b6028806080016080811067ffffffffffffffff8211171561005e5761005d6100cb565b5b50806100e560803980608083f01515610079573d82833e3d82fd5b508061008482610092565bf35b505b60006000fd6100e3565b60006040519050601f19601f830116810181811067ffffffffffffffff821117156100c0576100bf6100cb565b5b80604052505b919050565b634e487b7160e01b600052604160045260246000fd5b565bfe60806040523415600f5760006000fd5b600a80601e600039806000f350fe608060405260006000fd +608060405234156100105760006000fd5b60fb80610020600039806000f350fe6080604052600436101515610087576000803560e01c6326121ff0141561008557341561002a578081fd5b806003193601121561003a578081fd5b6028806080016080811067ffffffffffffffff8211171561005e5761005d6100b9565b5b50806100d360803980608083f01515610079573d82833e3d82fd5b5080610083610091565bf35b505b60006000fd6100d1565b6000604051905067ffffffffffffffff8111156100b1576100b06100b9565b5b806040525b90565b634e487b7160e01b600052604160045260246000fd5b565bfe60806040523415600f5760006000fd5b600a80601e600039806000f350fe608060405260006000fd Binary of the runtime part: -6080604052600436101515610088576000803560e01c6326121ff0141561008657341561002a578081fd5b806003193601121561003a578081fd5b6028806080016080811067ffffffffffffffff8211171561005e5761005d6100cb565b5b50806100e560803980608083f01515610079573d82833e3d82fd5b508061008482610092565bf35b505b60006000fd6100e3565b60006040519050601f19601f830116810181811067ffffffffffffffff821117156100c0576100bf6100cb565b5b80604052505b919050565b634e487b7160e01b600052604160045260246000fd5b565bfe60806040523415600f5760006000fd5b600a80601e600039806000f350fe608060405260006000fd +6080604052600436101515610087576000803560e01c6326121ff0141561008557341561002a578081fd5b806003193601121561003a578081fd5b6028806080016080811067ffffffffffffffff8211171561005e5761005d6100b9565b5b50806100d360803980608083f01515610079573d82833e3d82fd5b5080610083610091565bf35b505b60006000fd6100d1565b6000604051905067ffffffffffffffff8111156100b1576100b06100b9565b5b806040525b90565b634e487b7160e01b600052604160045260246000fd5b565bfe60806040523415600f5760006000fd5b600a80601e600039806000f350fe608060405260006000fd Optimized IR: /******************************************************* * WARNING * @@ -76,17 +76,16 @@ object "D_16" { returndatacopy(_1, _1, returndatasize()) revert(_1, returndatasize()) } - return(allocate_memory(_1), _1) + return(allocate_memory(), _1) } } revert(0, 0) } - function allocate_memory(size) -> memPtr + function allocate_memory() -> memPtr { memPtr := mload(64) - let newFreePtr := add(memPtr, and(add(size, 31), not(31))) - if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr)) { panic_error_0x41() } - mstore(64, newFreePtr) + if gt(memPtr, 0xffffffffffffffff) { panic_error_0x41() } + mstore(64, memPtr) } function panic_error_0x41() { diff --git a/test/libsolidity/gasTests/abiv2_optimised.sol b/test/libsolidity/gasTests/abiv2_optimised.sol index 382a4d135..5ad314f59 100644 --- a/test/libsolidity/gasTests/abiv2_optimised.sol +++ b/test/libsolidity/gasTests/abiv2_optimised.sol @@ -17,9 +17,9 @@ contract C { // optimize-yul: true // ---- // creation: -// codeDepositCost: 571400 -// executionCost: 606 -// totalCost: 572006 +// codeDepositCost: 626600 +// executionCost: 657 +// totalCost: 627257 // external: // a(): 985 // b(uint256): 2052 diff --git a/test/libsolidity/semanticTests/abiEncoderV1/abi_decode_v2_storage.sol b/test/libsolidity/semanticTests/abiEncoderV1/abi_decode_v2_storage.sol index 18cd81806..25e9fef00 100644 --- a/test/libsolidity/semanticTests/abiEncoderV1/abi_decode_v2_storage.sol +++ b/test/libsolidity/semanticTests/abiEncoderV1/abi_decode_v2_storage.sol @@ -24,6 +24,6 @@ contract C { // compileViaYul: also // ---- // f() -> 0x20, 0x8, 0x40, 0x3, 0x9, 0xa, 0xb -// gas irOptimized: 194174 +// gas irOptimized: 193697 // gas legacy: 196426 -// gas legacyOptimized: 193425 +// gas legacyOptimized: 193405 diff --git a/test/libsolidity/semanticTests/abiEncoderV1/abi_encode_calldata_slice.sol b/test/libsolidity/semanticTests/abiEncoderV1/abi_encode_calldata_slice.sol index a76565773..f273da760 100644 --- a/test/libsolidity/semanticTests/abiEncoderV1/abi_encode_calldata_slice.sol +++ b/test/libsolidity/semanticTests/abiEncoderV1/abi_encode_calldata_slice.sol @@ -60,10 +60,10 @@ contract C { // compileViaYul: also // ---- // test_bytes() -> -// gas irOptimized: 516922 +// gas irOptimized: 511133 // gas legacy: 466763 // gas legacyOptimized: 374537 // test_uint256() -> -// gas irOptimized: 712564 +// gas irOptimized: 706775 // gas legacy: 634592 // gas legacyOptimized: 499373 diff --git a/test/libsolidity/semanticTests/abiEncoderV1/struct/struct_storage_ptr.sol b/test/libsolidity/semanticTests/abiEncoderV1/struct/struct_storage_ptr.sol index 8e3ae7694..61bc36291 100644 --- a/test/libsolidity/semanticTests/abiEncoderV1/struct/struct_storage_ptr.sol +++ b/test/libsolidity/semanticTests/abiEncoderV1/struct/struct_storage_ptr.sol @@ -26,6 +26,6 @@ contract C { // ---- // library: L // f() -> 8, 7, 1, 2, 7, 12 -// gas irOptimized: 172123 +// gas irOptimized: 165254 // gas legacy: 164775 // gas legacyOptimized: 162697 diff --git a/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_calldata_slice.sol b/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_calldata_slice.sol index a47013cd9..7dc808d53 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_calldata_slice.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_calldata_slice.sol @@ -61,10 +61,10 @@ contract C { // compileViaYul: also // ---- // test_bytes() -> -// gas irOptimized: 516922 +// gas irOptimized: 511133 // gas legacy: 466763 // gas legacyOptimized: 374537 // test_uint256() -> -// gas irOptimized: 712564 +// gas irOptimized: 706775 // gas legacy: 634592 // gas legacyOptimized: 499373 diff --git a/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_v2.sol b/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_v2.sol index 600aced74..2f82a8413 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_v2.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_v2.sol @@ -53,6 +53,6 @@ contract C { // f2() -> 0x20, 0xa0, 0x1, 0x60, 0x2, 0x3, "abc" // f3() -> 0x20, 0xa0, 0x1, 0x60, 0x2, 0x3, "abc" // f4() -> 0x20, 0x160, 0x1, 0x80, 0xc0, 0x2, 0x3, "abc", 0x7, 0x40, 0x2, 0x2, 0x3 -// gas irOptimized: 110858 +// gas irOptimized: 110468 // gas legacy: 111328 // gas legacyOptimized: 109206 diff --git a/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_v2_in_function_inherited_in_v1_contract.sol b/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_v2_in_function_inherited_in_v1_contract.sol index 9fcbdcf3c..847c92397 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_v2_in_function_inherited_in_v1_contract.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_v2_in_function_inherited_in_v1_contract.sol @@ -30,6 +30,6 @@ contract C is B { // compileViaYul: also // ---- // test() -> 77 -// gas irOptimized: 139828 +// gas irOptimized: 142789 // gas legacy: 156573 -// gas legacyOptimized: 112983 +// gas legacyOptimized: 112940 diff --git a/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_v2_in_modifier_used_in_v1_contract.sol b/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_v2_in_modifier_used_in_v1_contract.sol index fa8f9c337..ddcb2a4b8 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_v2_in_modifier_used_in_v1_contract.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_v2_in_modifier_used_in_v1_contract.sol @@ -38,4 +38,5 @@ contract C is B { // compileViaYul: also // ---- // test() -> 5, 10 +// gas irOptimized: 101019 // gas legacy: 100441 diff --git a/test/libsolidity/semanticTests/abiEncoderV2/calldata_array.sol b/test/libsolidity/semanticTests/abiEncoderV2/calldata_array.sol index c4cb3cda2..66e4b77e3 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/calldata_array.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/calldata_array.sol @@ -21,6 +21,6 @@ contract C { // f(uint256[][1]): 32, 32, 0 -> true // f(uint256[][1]): 32, 32, 1, 42 -> true // f(uint256[][1]): 32, 32, 8, 421, 422, 423, 424, 425, 426, 427, 428 -> true -// gas irOptimized: 227647 +// gas irOptimized: 227280 // gas legacy: 144300 // gas legacyOptimized: 124189 diff --git a/test/libsolidity/semanticTests/abiEncoderV2/storage_array_encoding.sol b/test/libsolidity/semanticTests/abiEncoderV2/storage_array_encoding.sol index 630babe12..766824d7c 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/storage_array_encoding.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/storage_array_encoding.sol @@ -19,10 +19,10 @@ contract C { // compileViaYul: also // ---- // h(uint256[2][]): 0x20, 3, 123, 124, 223, 224, 323, 324 -> 32, 256, 0x20, 3, 123, 124, 223, 224, 323, 324 -// gas irOptimized: 172712 +// gas irOptimized: 172551 // gas legacy: 175929 // gas legacyOptimized: 172504 // i(uint256[2][2]): 123, 124, 223, 224 -> 32, 128, 123, 124, 223, 224 -// gas irOptimized: 107681 +// gas irOptimized: 107492 // gas legacy: 109868 // gas legacyOptimized: 107388 diff --git a/test/libsolidity/semanticTests/abiencodedecode/abi_decode_simple_storage.sol b/test/libsolidity/semanticTests/abiencodedecode/abi_decode_simple_storage.sol index 956da75e9..0af585712 100644 --- a/test/libsolidity/semanticTests/abiencodedecode/abi_decode_simple_storage.sol +++ b/test/libsolidity/semanticTests/abiencodedecode/abi_decode_simple_storage.sol @@ -11,6 +11,6 @@ contract C { // compileViaYul: also // ---- // f(bytes): 0x20, 0x80, 0x21, 0x40, 0x7, "abcdefg" -> 0x21, 0x40, 0x7, "abcdefg" -// gas irOptimized: 130299 +// gas irOptimized: 130202 // gas legacy: 131690 // gas legacyOptimized: 130577 diff --git a/test/libsolidity/semanticTests/array/arrays_complex_from_and_to_storage.sol b/test/libsolidity/semanticTests/array/arrays_complex_from_and_to_storage.sol index cbd79bfd2..8de7ab432 100644 --- a/test/libsolidity/semanticTests/array/arrays_complex_from_and_to_storage.sol +++ b/test/libsolidity/semanticTests/array/arrays_complex_from_and_to_storage.sol @@ -14,9 +14,9 @@ contract Test { // compileViaYul: also // ---- // set(uint24[3][]): 0x20, 0x06, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12 -> 0x06 -// gas irOptimized: 200167 +// gas irOptimized: 199798 // gas legacy: 278685 -// gas legacyOptimized: 273732 +// gas legacyOptimized: 273594 // data(uint256,uint256): 0x02, 0x02 -> 0x09 // data(uint256,uint256): 0x05, 0x01 -> 0x11 // data(uint256,uint256): 0x06, 0x00 -> FAILURE diff --git a/test/libsolidity/semanticTests/array/byte_array_storage_layout.sol b/test/libsolidity/semanticTests/array/byte_array_storage_layout.sol index 168a81734..daea59f3c 100644 --- a/test/libsolidity/semanticTests/array/byte_array_storage_layout.sol +++ b/test/libsolidity/semanticTests/array/byte_array_storage_layout.sol @@ -47,7 +47,7 @@ contract c { // gas legacyOptimized: 109706 // storage: nonempty // test_long() -> 67 -// gas irOptimized: 134698 +// gas irOptimized: 134469 // gas legacy: 213590 // gas legacyOptimized: 211044 // storage: nonempty diff --git a/test/libsolidity/semanticTests/array/byte_array_transitional_2.sol b/test/libsolidity/semanticTests/array/byte_array_transitional_2.sol index 6d73090f0..ca3f7771d 100644 --- a/test/libsolidity/semanticTests/array/byte_array_transitional_2.sol +++ b/test/libsolidity/semanticTests/array/byte_array_transitional_2.sol @@ -19,6 +19,6 @@ contract c { // compileViaYul: also // ---- // test() -> 0 -// gas irOptimized: 312322 +// gas irOptimized: 311507 // gas legacy: 483915 // gas legacyOptimized: 478672 diff --git a/test/libsolidity/semanticTests/array/bytes_length_member.sol b/test/libsolidity/semanticTests/array/bytes_length_member.sol index 91811da97..7e8b6c442 100644 --- a/test/libsolidity/semanticTests/array/bytes_length_member.sol +++ b/test/libsolidity/semanticTests/array/bytes_length_member.sol @@ -15,7 +15,7 @@ contract c { // ---- // getLength() -> 0 // set(): 1, 2 -> true -// gas irOptimized: 103207 +// gas irOptimized: 103153 // gas legacy: 103126 // gas legacyOptimized: 102967 // getLength() -> 68 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_calldata_storage.sol b/test/libsolidity/semanticTests/array/copying/array_copy_calldata_storage.sol index f713f9e00..1d6eecf95 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_calldata_storage.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_calldata_storage.sol @@ -22,7 +22,7 @@ contract c { // compileViaYul: also // ---- // store(uint256[9],uint8[3][]): 21, 22, 23, 24, 25, 26, 27, 28, 29, 0x140, 4, 1, 2, 3, 11, 12, 13, 21, 22, 23, 31, 32, 33 -> 32 -// gas irOptimized: 628978 +// gas irOptimized: 612370 // gas legacy: 817315 // gas legacyOptimized: 816813 // retrieve() -> 9, 28, 9, 28, 4, 3, 32 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_cleanup_uint128.sol b/test/libsolidity/semanticTests/array/copying/array_copy_cleanup_uint128.sol index 7b9afb54b..faf386128 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_cleanup_uint128.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_cleanup_uint128.sol @@ -23,6 +23,6 @@ contract C { // compileViaYul: also // ---- // f() -> true -// gas irOptimized: 111965 +// gas irOptimized: 107807 // gas legacy: 107335 // gas legacyOptimized: 105857 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_cleanup_uint40.sol b/test/libsolidity/semanticTests/array/copying/array_copy_cleanup_uint40.sol index 03c12c72f..beca99285 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_cleanup_uint40.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_cleanup_uint40.sol @@ -48,6 +48,6 @@ contract C { // compileViaYul: also // ---- // f() -> true -// gas irOptimized: 253493 +// gas irOptimized: 233902 // gas legacy: 239061 // gas legacyOptimized: 235988 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_clear_storage.sol b/test/libsolidity/semanticTests/array/copying/array_copy_clear_storage.sol index f6e21cc29..752a9f1ce 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_clear_storage.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_clear_storage.sol @@ -15,6 +15,6 @@ contract C { // compileViaYul: also // ---- // f() -> 0 -// gas irOptimized: 150525 +// gas irOptimized: 139626 // gas legacy: 138913 // gas legacyOptimized: 137448 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_clear_storage_packed.sol b/test/libsolidity/semanticTests/array/copying/array_copy_clear_storage_packed.sol index 64cdc728b..411fd7ff6 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_clear_storage_packed.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_clear_storage_packed.sol @@ -42,11 +42,11 @@ contract C { // compileViaYul: also // ---- // f() -> 0 -// gas irOptimized: 111968 +// gas irOptimized: 107769 // gas legacy: 107306 // gas legacyOptimized: 105861 // g() -> 0 // h() -> 0 -// gas irOptimized: 112011 +// gas irOptimized: 107820 // gas legacy: 107328 // gas legacyOptimized: 105903 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_different_packing.sol b/test/libsolidity/semanticTests/array/copying/array_copy_different_packing.sol index 925b3b1a0..9c0c9783d 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_different_packing.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_different_packing.sol @@ -21,6 +21,6 @@ contract c { // compileViaYul: also // ---- // test() -> 0x01000000000000000000000000000000000000000000000000, 0x02000000000000000000000000000000000000000000000000, 0x03000000000000000000000000000000000000000000000000, 0x04000000000000000000000000000000000000000000000000, 0x05000000000000000000000000000000000000000000000000 -// gas irOptimized: 247460 +// gas irOptimized: 246856 // gas legacy: 276683 // gas legacyOptimized: 275534 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_including_array.sol b/test/libsolidity/semanticTests/array/copying/array_copy_including_array.sol index 5978a6adc..d757524d8 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_including_array.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_including_array.sol @@ -37,12 +37,12 @@ contract c { // compileViaYul: also // ---- // test() -> 0x02000202 -// gas irOptimized: 2481119 +// gas irOptimized: 2477836 // gas legacy: 2288641 // gas legacyOptimized: 2258654 // storage: empty // clear() -> 0, 0 -// gas irOptimized: 1856784 +// gas irOptimized: 1854274 // gas legacy: 1727169 // gas legacyOptimized: 1698931 // storage: empty diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_nested_array.sol b/test/libsolidity/semanticTests/array/copying/array_copy_nested_array.sol index f5f48f710..03f85304e 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_nested_array.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_nested_array.sol @@ -15,6 +15,6 @@ contract c { // compileViaYul: also // ---- // test(uint256[2][]): 32, 3, 7, 8, 9, 10, 11, 12 -> 10 -// gas irOptimized: 611490 +// gas irOptimized: 610623 // gas legacy: 604268 // gas legacyOptimized: 603688 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_different_base.sol b/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_different_base.sol index 6427c5b9e..610484246 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_different_base.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_different_base.sol @@ -19,6 +19,6 @@ contract c { // compileViaYul: also // ---- // test() -> 5, 4 -// gas irOptimized: 235594 +// gas irOptimized: 235198 // gas legacy: 237001 // gas legacyOptimized: 235316 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_different_base_nested.sol b/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_different_base_nested.sol index 5b9c1a6ff..140905ada 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_different_base_nested.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_different_base_nested.sol @@ -23,6 +23,6 @@ contract c { // compileViaYul: also // ---- // test() -> 3, 4 -// gas irOptimized: 195483 +// gas irOptimized: 191241 // gas legacy: 208853 // gas legacyOptimized: 200341 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_dynamic_dynamic.sol b/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_dynamic_dynamic.sol index e645eedee..8674acf46 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_dynamic_dynamic.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_dynamic_dynamic.sol @@ -20,6 +20,6 @@ contract c { // compileViaYul: also // ---- // test() -> 5, 4 -// gas irOptimized: 276018 +// gas irOptimized: 265237 // gas legacy: 264734 // gas legacyOptimized: 263160 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_static_dynamic.sol b/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_static_dynamic.sol index e9d877640..072ecefe1 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_static_dynamic.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_static_dynamic.sol @@ -14,4 +14,4 @@ contract c { // compileViaYul: also // ---- // test() -> 9, 4 -// gas irOptimized: 100283 +// gas irOptimized: 99282 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_static_static.sol b/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_static_static.sol index 7761f10bd..10e75870c 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_static_static.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_static_static.sol @@ -18,6 +18,6 @@ contract c { // compileViaYul: also // ---- // test() -> 8, 0 -// gas irOptimized: 158923 +// gas irOptimized: 154937 // gas legacy: 153995 // gas legacyOptimized: 153403 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_struct.sol b/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_struct.sol index 399732940..1b72dc099 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_struct.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_struct.sol @@ -19,7 +19,7 @@ contract c { // compileViaYul: also // ---- // test() -> 4, 5 -// gas irOptimized: 282808 +// gas irOptimized: 259287 // gas legacy: 255936 // gas legacyOptimized: 254359 // storage: empty diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_storage_to_memory_nested.sol b/test/libsolidity/semanticTests/array/copying/array_copy_storage_to_memory_nested.sol index be8c70a23..b7d6608e1 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_storage_to_memory_nested.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_storage_to_memory_nested.sol @@ -17,6 +17,6 @@ contract C { // compileViaYul: also // ---- // f() -> 0x20, 2, 0x40, 0xa0, 2, 0, 1, 2, 2, 3 -// gas irOptimized: 170692 +// gas irOptimized: 168769 // gas legacy: 163978 // gas legacyOptimized: 158150 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_target_leftover.sol b/test/libsolidity/semanticTests/array/copying/array_copy_target_leftover.sol index 97ed1ef39..202af3d05 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_target_leftover.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_target_leftover.sol @@ -19,6 +19,6 @@ contract c { // compileViaYul: also // ---- // test() -> 0xffffffff, 0x0000000000000000000000000a00090008000700060005000400030002000100, 0x0000000000000000000000000000000000000000000000000000000000000000 -// gas irOptimized: 222905 +// gas irOptimized: 218689 // gas legacy: 328106 -// gas legacyOptimized: 308072 +// gas legacyOptimized: 307826 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_target_leftover2.sol b/test/libsolidity/semanticTests/array/copying/array_copy_target_leftover2.sol index 9818f77dc..f83d76e3f 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_target_leftover2.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_target_leftover2.sol @@ -21,6 +21,6 @@ contract c { // compileViaYul: also // ---- // test() -> 0x04000000000000000000000000000000000000000000000000, 0x0, 0x0 -// gas irOptimized: 109180 +// gas irOptimized: 107799 // gas legacy: 116651 // gas legacyOptimized: 107000 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_target_simple.sol b/test/libsolidity/semanticTests/array/copying/array_copy_target_simple.sol index 4c6bd2b68..7c9bd010a 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_target_simple.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_target_simple.sol @@ -21,6 +21,6 @@ contract c { // compileViaYul: also // ---- // test() -> 0x01000000000000000000000000000000000000000000000000, 0x02000000000000000000000000000000000000000000000000, 0x03000000000000000000000000000000000000000000000000, 0x04000000000000000000000000000000000000000000000000, 0x0 -// gas irOptimized: 290176 +// gas irOptimized: 288963 // gas legacy: 309353 // gas legacyOptimized: 307699 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_target_simple_2.sol b/test/libsolidity/semanticTests/array/copying/array_copy_target_simple_2.sol index a5ba42049..7f5aed3e8 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_target_simple_2.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_target_simple_2.sol @@ -21,6 +21,6 @@ contract c { // compileViaYul: also // ---- // test() -> 0x01000000000000000000000000000000000000000000000000, 0x02000000000000000000000000000000000000000000000000, 0x03000000000000000000000000000000000000000000000000, 0x04000000000000000000000000000000000000000000000000, 0x00 -// gas irOptimized: 269679 +// gas irOptimized: 264046 // gas legacy: 269681 // gas legacyOptimized: 268753 diff --git a/test/libsolidity/semanticTests/array/copying/array_nested_calldata_to_storage.sol b/test/libsolidity/semanticTests/array/copying/array_nested_calldata_to_storage.sol index 453c075bf..48df94fe9 100644 --- a/test/libsolidity/semanticTests/array/copying/array_nested_calldata_to_storage.sol +++ b/test/libsolidity/semanticTests/array/copying/array_nested_calldata_to_storage.sol @@ -38,10 +38,10 @@ contract c { // compileViaYul: true // ---- // test1(uint256[][]): 0x20, 2, 0x40, 0x40, 2, 23, 42 -> 2, 65 -// gas irOptimized: 179750 +// gas irOptimized: 179347 // test2(uint256[][2]): 0x20, 0x40, 0x40, 2, 23, 42 -> 2, 65 -// gas irOptimized: 155229 +// gas irOptimized: 154097 // test3(uint256[2][]): 0x20, 2, 23, 42, 23, 42 -> 2, 65 -// gas irOptimized: 133495 +// gas irOptimized: 132762 // test4(uint256[2][2]): 23, 42, 23, 42 -> 65 -// gas irOptimized: 107858 +// gas irOptimized: 105500 diff --git a/test/libsolidity/semanticTests/array/copying/array_nested_memory_to_storage.sol b/test/libsolidity/semanticTests/array/copying/array_nested_memory_to_storage.sol index 7b5d03540..e931c738f 100644 --- a/test/libsolidity/semanticTests/array/copying/array_nested_memory_to_storage.sol +++ b/test/libsolidity/semanticTests/array/copying/array_nested_memory_to_storage.sol @@ -40,12 +40,12 @@ contract Test { // compileViaYul: also // ---- // test() -> 24 -// gas irOptimized: 217724 +// gas irOptimized: 216554 // gas legacy: 215533 // gas legacyOptimized: 214947 // test1() -> 3 // test2() -> 6 // test3() -> 24 -// gas irOptimized: 124650 +// gas irOptimized: 123067 // gas legacy: 122795 // gas legacyOptimized: 121883 diff --git a/test/libsolidity/semanticTests/array/copying/array_of_struct_calldata_to_storage.sol b/test/libsolidity/semanticTests/array/copying/array_of_struct_calldata_to_storage.sol index 0f77fd960..caa5d031e 100644 --- a/test/libsolidity/semanticTests/array/copying/array_of_struct_calldata_to_storage.sol +++ b/test/libsolidity/semanticTests/array/copying/array_of_struct_calldata_to_storage.sol @@ -17,4 +17,4 @@ contract C { // compileViaYul: true // ---- // f((uint128,uint64,uint128)[]): 0x20, 3, 0, 0, 12, 0, 11, 0, 10, 0, 0 -> 10, 11, 12 -// gas irOptimized: 123321 +// gas irOptimized: 123100 diff --git a/test/libsolidity/semanticTests/array/copying/array_of_struct_memory_to_storage.sol b/test/libsolidity/semanticTests/array/copying/array_of_struct_memory_to_storage.sol index 9e7fc1041..d00f51ed4 100644 --- a/test/libsolidity/semanticTests/array/copying/array_of_struct_memory_to_storage.sol +++ b/test/libsolidity/semanticTests/array/copying/array_of_struct_memory_to_storage.sol @@ -19,4 +19,4 @@ contract C { // compileViaYul: true // ---- // f() -> 10, 11, 12 -// gas irOptimized: 122679 +// gas irOptimized: 122096 diff --git a/test/libsolidity/semanticTests/array/copying/array_of_structs_containing_arrays_calldata_to_storage.sol b/test/libsolidity/semanticTests/array/copying/array_of_structs_containing_arrays_calldata_to_storage.sol index 16eea0b55..90e2dd1a6 100644 --- a/test/libsolidity/semanticTests/array/copying/array_of_structs_containing_arrays_calldata_to_storage.sol +++ b/test/libsolidity/semanticTests/array/copying/array_of_structs_containing_arrays_calldata_to_storage.sol @@ -23,4 +23,4 @@ contract C { // compileViaYul: true // ---- // f((uint256[])[]): 0x20, 3, 0x60, 0x60, 0x60, 0x20, 3, 1, 2, 3 -> 3, 1 -// gas irOptimized: 354491 +// gas irOptimized: 354017 diff --git a/test/libsolidity/semanticTests/array/copying/array_of_structs_containing_arrays_memory_to_storage.sol b/test/libsolidity/semanticTests/array/copying/array_of_structs_containing_arrays_memory_to_storage.sol index f908e8b42..4c3135708 100644 --- a/test/libsolidity/semanticTests/array/copying/array_of_structs_containing_arrays_memory_to_storage.sol +++ b/test/libsolidity/semanticTests/array/copying/array_of_structs_containing_arrays_memory_to_storage.sol @@ -26,4 +26,4 @@ contract C { // compileViaYul: true // ---- // f() -> 3, 3, 3, 1 -// gas irOptimized: 189735 +// gas irOptimized: 187687 diff --git a/test/libsolidity/semanticTests/array/copying/array_storage_multi_items_per_slot.sol b/test/libsolidity/semanticTests/array/copying/array_storage_multi_items_per_slot.sol index 31f54f591..966f66d76 100644 --- a/test/libsolidity/semanticTests/array/copying/array_storage_multi_items_per_slot.sol +++ b/test/libsolidity/semanticTests/array/copying/array_storage_multi_items_per_slot.sol @@ -15,6 +15,6 @@ contract C { // compileViaYul: also // ---- // f() -> 1, 2, 3 -// gas irOptimized: 135042 +// gas irOptimized: 133583 // gas legacy: 134419 // gas legacyOptimized: 125440 diff --git a/test/libsolidity/semanticTests/array/copying/arrays_from_and_to_storage.sol b/test/libsolidity/semanticTests/array/copying/arrays_from_and_to_storage.sol index c1d7d4d6c..e4d2c13aa 100644 --- a/test/libsolidity/semanticTests/array/copying/arrays_from_and_to_storage.sol +++ b/test/libsolidity/semanticTests/array/copying/arrays_from_and_to_storage.sol @@ -12,7 +12,7 @@ contract Test { // compileViaYul: also // ---- // set(uint24[]): 0x20, 18, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18 -> 18 -// gas irOptimized: 121109 +// gas irOptimized: 121010 // gas legacy: 125815 // gas legacyOptimized: 123614 // data(uint256): 7 -> 8 diff --git a/test/libsolidity/semanticTests/array/copying/bytes_inside_mappings.sol b/test/libsolidity/semanticTests/array/copying/bytes_inside_mappings.sol index 25d541f71..af67f0eda 100644 --- a/test/libsolidity/semanticTests/array/copying/bytes_inside_mappings.sol +++ b/test/libsolidity/semanticTests/array/copying/bytes_inside_mappings.sol @@ -7,11 +7,11 @@ contract c { // compileViaYul: also // ---- // set(uint256): 1, 2 -> true -// gas irOptimized: 103359 +// gas irOptimized: 103311 // gas legacy: 103491 // gas legacyOptimized: 103136 // set(uint256): 2, 2, 3, 4, 5 -> true -// gas irOptimized: 164046 +// gas irOptimized: 163998 // gas legacy: 164121 // gas legacyOptimized: 163766 // storage: nonempty diff --git a/test/libsolidity/semanticTests/array/copying/bytes_storage_to_storage.sol b/test/libsolidity/semanticTests/array/copying/bytes_storage_to_storage.sol index eec2b723d..0643ae925 100644 --- a/test/libsolidity/semanticTests/array/copying/bytes_storage_to_storage.sol +++ b/test/libsolidity/semanticTests/array/copying/bytes_storage_to_storage.sol @@ -19,25 +19,25 @@ contract c { // ---- // f(uint256): 0 -> 0x20, 0x00 // f(uint256): 31 -> 0x20, 0x1f, 0x0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e00 -// gas irOptimized: 222425 +// gas irOptimized: 221795 // gas legacy: 255464 // gas legacyOptimized: 250998 // f(uint256): 32 -> 0x20, 0x20, 1780731860627700044960722568376592200742329637303199754547598369979440671 -// gas irOptimized: 233052 +// gas irOptimized: 232383 // gas legacy: 267931 // gas legacyOptimized: 263329 // f(uint256): 33 -> 0x20, 33, 1780731860627700044960722568376592200742329637303199754547598369979440671, 0x2000000000000000000000000000000000000000000000000000000000000000 -// gas irOptimized: 241863 +// gas irOptimized: 241178 // gas legacy: 277538 // gas legacyOptimized: 272818 // f(uint256): 63 -> 0x20, 0x3f, 1780731860627700044960722568376592200742329637303199754547598369979440671, 14532552714582660066924456880521368950258152170031413196862950297402215316992 -// gas irOptimized: 355653 +// gas irOptimized: 354488 // gas legacy: 423428 // gas legacyOptimized: 414868 // f(uint256): 12 -> 0x20, 0x0c, 0x0102030405060708090a0b0000000000000000000000000000000000000000 // gas legacy: 106445 // gas legacyOptimized: 104379 // f(uint256): 129 -> 0x20, 0x81, 1780731860627700044960722568376592200742329637303199754547598369979440671, 0x202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f, 29063324697304692433803953038474361308315562010425523193971352996434451193439, 0x606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f, -57896044618658097711785492504343953926634992332820282019728792003956564819968 -// gas irOptimized: 816179 +// gas irOptimized: 813943 // gas legacy: 954517 // gas legacyOptimized: 937521 diff --git a/test/libsolidity/semanticTests/array/copying/calldata_array_dynamic_to_storage.sol b/test/libsolidity/semanticTests/array/copying/calldata_array_dynamic_to_storage.sol index d3afcdf24..8ed7adc23 100644 --- a/test/libsolidity/semanticTests/array/copying/calldata_array_dynamic_to_storage.sol +++ b/test/libsolidity/semanticTests/array/copying/calldata_array_dynamic_to_storage.sol @@ -11,6 +11,6 @@ contract C { // compileViaYul: also // ---- // f(uint256[]): 0x20, 0x03, 0x1, 0x2, 0x3 -> 0x1 -// gas irOptimized: 108090 +// gas irOptimized: 105320 // gas legacy: 105365 // gas legacyOptimized: 105147 diff --git a/test/libsolidity/semanticTests/array/copying/copy_byte_array_in_struct_to_storage.sol b/test/libsolidity/semanticTests/array/copying/copy_byte_array_in_struct_to_storage.sol index e174dd38d..c6d9a95bf 100644 --- a/test/libsolidity/semanticTests/array/copying/copy_byte_array_in_struct_to_storage.sol +++ b/test/libsolidity/semanticTests/array/copying/copy_byte_array_in_struct_to_storage.sol @@ -37,7 +37,7 @@ contract C { // compileViaYul: also // ---- // f() -> 0x40, 0x80, 6, 0x6162636465660000000000000000000000000000000000000000000000000000, 0x49, 0x3132333435363738393031323334353637383930313233343536373839303120, 0x3132333435363738393031323334353637383930313233343536373839303120, 0x3132333435363738390000000000000000000000000000000000000000000000 -// gas irOptimized: 172876 +// gas irOptimized: 172472 // gas legacy: 174794 // gas legacyOptimized: 174188 // g() -> 0x40, 0xc0, 0x49, 0x3132333435363738393031323334353637383930313233343536373839303120, 0x3132333435363738393031323334353637383930313233343536373839303120, 0x3132333435363738390000000000000000000000000000000000000000000000, 0x11, 0x3132333435363738393233343536373839000000000000000000000000000000 diff --git a/test/libsolidity/semanticTests/array/copying/copy_byte_array_to_storage.sol b/test/libsolidity/semanticTests/array/copying/copy_byte_array_to_storage.sol index fef894c27..cd2775910 100644 --- a/test/libsolidity/semanticTests/array/copying/copy_byte_array_to_storage.sol +++ b/test/libsolidity/semanticTests/array/copying/copy_byte_array_to_storage.sol @@ -48,6 +48,6 @@ contract C { // compileViaYul: also // ---- // f() -> 0xff -// gas irOptimized: 137415 +// gas irOptimized: 136355 // gas legacy: 137645 // gas legacyOptimized: 134376 diff --git a/test/libsolidity/semanticTests/array/copying/copy_function_storage_array.sol b/test/libsolidity/semanticTests/array/copying/copy_function_storage_array.sol index 846df6375..674ee394e 100644 --- a/test/libsolidity/semanticTests/array/copying/copy_function_storage_array.sol +++ b/test/libsolidity/semanticTests/array/copying/copy_function_storage_array.sol @@ -18,6 +18,6 @@ contract C { // compileViaYul: also // ---- // test() -> 7 -// gas irOptimized: 134680 +// gas irOptimized: 134260 // gas legacy: 211296 // gas legacyOptimized: 211087 diff --git a/test/libsolidity/semanticTests/array/copying/copy_removes_bytes_data.sol b/test/libsolidity/semanticTests/array/copying/copy_removes_bytes_data.sol index 61e30731b..6de168c76 100644 --- a/test/libsolidity/semanticTests/array/copying/copy_removes_bytes_data.sol +++ b/test/libsolidity/semanticTests/array/copying/copy_removes_bytes_data.sol @@ -9,7 +9,7 @@ contract c { // compileViaYul: also // ---- // set(): 1, 2, 3, 4, 5 -> true -// gas irOptimized: 163855 +// gas irOptimized: 163790 // gas legacy: 163756 // gas legacyOptimized: 163596 // storage: nonempty diff --git a/test/libsolidity/semanticTests/array/copying/memory_dyn_2d_bytes_to_storage.sol b/test/libsolidity/semanticTests/array/copying/memory_dyn_2d_bytes_to_storage.sol index 03c2c813f..77f050cdd 100644 --- a/test/libsolidity/semanticTests/array/copying/memory_dyn_2d_bytes_to_storage.sol +++ b/test/libsolidity/semanticTests/array/copying/memory_dyn_2d_bytes_to_storage.sol @@ -20,6 +20,6 @@ contract C { // compileViaYul: also // ---- // f() -> 3 -// gas irOptimized: 175175 +// gas irOptimized: 174259 // gas legacy: 179707 // gas legacyOptimized: 178763 diff --git a/test/libsolidity/semanticTests/array/copying/storage_memory_nested.sol b/test/libsolidity/semanticTests/array/copying/storage_memory_nested.sol index 68e68e85a..eb7aae123 100644 --- a/test/libsolidity/semanticTests/array/copying/storage_memory_nested.sol +++ b/test/libsolidity/semanticTests/array/copying/storage_memory_nested.sol @@ -19,6 +19,6 @@ contract C { // compileViaYul: also // ---- // f() -> 1, 2, 3, 4, 5, 6, 7 -// gas irOptimized: 218088 +// gas irOptimized: 212697 // gas legacy: 223725 // gas legacyOptimized: 222886 diff --git a/test/libsolidity/semanticTests/array/copying/storage_memory_nested_bytes.sol b/test/libsolidity/semanticTests/array/copying/storage_memory_nested_bytes.sol index 778d172c6..2a21b55e2 100644 --- a/test/libsolidity/semanticTests/array/copying/storage_memory_nested_bytes.sol +++ b/test/libsolidity/semanticTests/array/copying/storage_memory_nested_bytes.sol @@ -13,6 +13,6 @@ contract C { // compileViaYul: also // ---- // f() -> 0x20, 0x02, 0x40, 0x80, 3, 0x6162630000000000000000000000000000000000000000000000000000000000, 0x99, 44048183304486788312148433451363384677562265908331949128489393215789685032262, 32241931068525137014058842823026578386641954854143559838526554899205067598957, 49951309422467613961193228765530489307475214998374779756599339590522149884499, 0x54555658595a6162636465666768696a6b6c6d6e6f707172737475767778797a, 0x4142434445464748494a4b4c4d4e4f5051525354555658595a00000000000000 -// gas irOptimized: 198770 +// gas irOptimized: 198455 // gas legacy: 199159 // gas legacyOptimized: 198132 diff --git a/test/libsolidity/semanticTests/array/copying/storage_memory_nested_from_pointer.sol b/test/libsolidity/semanticTests/array/copying/storage_memory_nested_from_pointer.sol index 69b80a2b4..f72b67db2 100644 --- a/test/libsolidity/semanticTests/array/copying/storage_memory_nested_from_pointer.sol +++ b/test/libsolidity/semanticTests/array/copying/storage_memory_nested_from_pointer.sol @@ -20,6 +20,6 @@ contract C { // compileViaYul: also // ---- // f() -> 1, 2, 3, 4, 5, 6, 7 -// gas irOptimized: 218088 +// gas irOptimized: 212697 // gas legacy: 223730 // gas legacyOptimized: 222891 diff --git a/test/libsolidity/semanticTests/array/copying/storage_memory_nested_struct.sol b/test/libsolidity/semanticTests/array/copying/storage_memory_nested_struct.sol index 8fdd1bec9..0776b830d 100644 --- a/test/libsolidity/semanticTests/array/copying/storage_memory_nested_struct.sol +++ b/test/libsolidity/semanticTests/array/copying/storage_memory_nested_struct.sol @@ -26,6 +26,6 @@ contract C { // compileViaYul: also // ---- // f() -> 11, 0x0c, 1, 0x15, 22, 4 -// gas irOptimized: 292610 +// gas irOptimized: 289378 // gas legacy: 296916 // gas legacyOptimized: 283163 diff --git a/test/libsolidity/semanticTests/array/copying/storage_memory_packed_dyn.sol b/test/libsolidity/semanticTests/array/copying/storage_memory_packed_dyn.sol index 57a646419..46ebaa181 100644 --- a/test/libsolidity/semanticTests/array/copying/storage_memory_packed_dyn.sol +++ b/test/libsolidity/semanticTests/array/copying/storage_memory_packed_dyn.sol @@ -15,6 +15,6 @@ contract C { // compileViaYul: also // ---- // f() -> 2, 3, 4 -// gas irOptimized: 240291 +// gas irOptimized: 209867 // gas legacy: 241549 // gas legacyOptimized: 236002 diff --git a/test/libsolidity/semanticTests/array/create_memory_array.sol b/test/libsolidity/semanticTests/array/create_memory_array.sol index 464da32ba..5bab95a3f 100644 --- a/test/libsolidity/semanticTests/array/create_memory_array.sol +++ b/test/libsolidity/semanticTests/array/create_memory_array.sol @@ -20,6 +20,6 @@ contract C { // compileViaYul: also // ---- // f() -> "A", 8, 4, "B" -// gas irOptimized: 170553 +// gas irOptimized: 151068 // gas legacy: 121398 // gas legacyOptimized: 115494 diff --git a/test/libsolidity/semanticTests/array/delete/bytes_delete_element.sol b/test/libsolidity/semanticTests/array/delete/bytes_delete_element.sol index 327c59f5d..abcb6333b 100644 --- a/test/libsolidity/semanticTests/array/delete/bytes_delete_element.sol +++ b/test/libsolidity/semanticTests/array/delete/bytes_delete_element.sol @@ -18,6 +18,6 @@ contract c { // compileViaYul: also // ---- // test1() -> true -// gas irOptimized: 533377 +// gas irOptimized: 531791 // gas legacy: 613377 // gas legacyOptimized: 606411 diff --git a/test/libsolidity/semanticTests/array/delete/delete_storage_array_packed.sol b/test/libsolidity/semanticTests/array/delete/delete_storage_array_packed.sol index 9811c27be..b17f06c13 100644 --- a/test/libsolidity/semanticTests/array/delete/delete_storage_array_packed.sol +++ b/test/libsolidity/semanticTests/array/delete/delete_storage_array_packed.sol @@ -16,4 +16,4 @@ contract C { // compileViaYul: also // ---- // f() -> 0, 0, 0 -// gas irOptimized: 101909 +// gas irOptimized: 101644 diff --git a/test/libsolidity/semanticTests/array/dynamic_array_cleanup.sol b/test/libsolidity/semanticTests/array/dynamic_array_cleanup.sol index 6942a8fa3..500712af8 100644 --- a/test/libsolidity/semanticTests/array/dynamic_array_cleanup.sol +++ b/test/libsolidity/semanticTests/array/dynamic_array_cleanup.sol @@ -16,7 +16,7 @@ contract c { // ---- // storage: empty // fill() -> -// gas irOptimized: 536196 +// gas irOptimized: 535980 // gas legacy: 504373 // gas legacyOptimized: 499648 // storage: nonempty diff --git a/test/libsolidity/semanticTests/array/dynamic_arrays_in_storage.sol b/test/libsolidity/semanticTests/array/dynamic_arrays_in_storage.sol index c28cbf761..8055248f0 100644 --- a/test/libsolidity/semanticTests/array/dynamic_arrays_in_storage.sol +++ b/test/libsolidity/semanticTests/array/dynamic_arrays_in_storage.sol @@ -44,7 +44,7 @@ contract c { // ---- // getLengths() -> 0, 0 // setLengths(uint256,uint256): 48, 49 -> -// gas irOptimized: 276350 +// gas irOptimized: 275906 // gas legacy: 308271 // gas legacyOptimized: 300117 // getLengths() -> 48, 49 diff --git a/test/libsolidity/semanticTests/array/dynamic_multi_array_cleanup.sol b/test/libsolidity/semanticTests/array/dynamic_multi_array_cleanup.sol index 38d3e3c35..b639f1db6 100644 --- a/test/libsolidity/semanticTests/array/dynamic_multi_array_cleanup.sol +++ b/test/libsolidity/semanticTests/array/dynamic_multi_array_cleanup.sol @@ -18,7 +18,7 @@ contract c { // ---- // storage: empty // fill() -> 8 -// gas irOptimized: 181160 +// gas irOptimized: 170158 // gas legacy: 165456 // gas legacyOptimized: 164387 // storage: nonempty diff --git a/test/libsolidity/semanticTests/array/fixed_array_cleanup.sol b/test/libsolidity/semanticTests/array/fixed_array_cleanup.sol index b87d65e6e..915b2423d 100644 --- a/test/libsolidity/semanticTests/array/fixed_array_cleanup.sol +++ b/test/libsolidity/semanticTests/array/fixed_array_cleanup.sol @@ -13,7 +13,7 @@ contract c { // ---- // storage: empty // fill() -> -// gas irOptimized: 423997 +// gas irOptimized: 423949 // gas legacy: 429460 // gas legacyOptimized: 425520 // storage: nonempty diff --git a/test/libsolidity/semanticTests/array/fixed_arrays_as_return_type.sol b/test/libsolidity/semanticTests/array/fixed_arrays_as_return_type.sol index cfa63486c..9cea17d0b 100644 --- a/test/libsolidity/semanticTests/array/fixed_arrays_as_return_type.sol +++ b/test/libsolidity/semanticTests/array/fixed_arrays_as_return_type.sol @@ -21,6 +21,6 @@ contract B { // compileViaYul: also // ---- // f() -> 2, 3, 4, 5, 6, 1000, 1001, 1002, 1003, 1004 -// gas irOptimized: 179451 +// gas irOptimized: 152350 // gas legacy: 264410 // gas legacyOptimized: 134899 diff --git a/test/libsolidity/semanticTests/array/function_array_cross_calls.sol b/test/libsolidity/semanticTests/array/function_array_cross_calls.sol index 47f7c00a3..f5ba1a31d 100644 --- a/test/libsolidity/semanticTests/array/function_array_cross_calls.sol +++ b/test/libsolidity/semanticTests/array/function_array_cross_calls.sol @@ -45,6 +45,6 @@ contract C { // compileViaYul: also // ---- // test() -> 5, 6, 7 -// gas irOptimized: 360198 +// gas irOptimized: 354715 // gas legacy: 500424 // gas legacyOptimized: 307813 diff --git a/test/libsolidity/semanticTests/array/pop/array_pop_array_transition.sol b/test/libsolidity/semanticTests/array/pop/array_pop_array_transition.sol index b75067cba..66e650987 100644 --- a/test/libsolidity/semanticTests/array/pop/array_pop_array_transition.sol +++ b/test/libsolidity/semanticTests/array/pop/array_pop_array_transition.sol @@ -25,7 +25,7 @@ contract c { // compileViaYul: also // ---- // test() -> 1, 2, 3 -// gas irOptimized: 2556747 +// gas irOptimized: 2462156 // gas legacy: 2416722 // gas legacyOptimized: 2405396 // storage: empty diff --git a/test/libsolidity/semanticTests/array/pop/array_pop_uint16_transition.sol b/test/libsolidity/semanticTests/array/pop/array_pop_uint16_transition.sol index 22e2cdf12..a21cb1469 100644 --- a/test/libsolidity/semanticTests/array/pop/array_pop_uint16_transition.sol +++ b/test/libsolidity/semanticTests/array/pop/array_pop_uint16_transition.sol @@ -20,7 +20,7 @@ contract c { // compileViaYul: also // ---- // test() -> 38, 28, 18 -// gas irOptimized: 538686 +// gas irOptimized: 531794 // gas legacy: 454080 // gas legacyOptimized: 443170 // storage: empty diff --git a/test/libsolidity/semanticTests/array/pop/array_pop_uint24_transition.sol b/test/libsolidity/semanticTests/array/pop/array_pop_uint24_transition.sol index d40fa3058..7889e9436 100644 --- a/test/libsolidity/semanticTests/array/pop/array_pop_uint24_transition.sol +++ b/test/libsolidity/semanticTests/array/pop/array_pop_uint24_transition.sol @@ -20,7 +20,7 @@ contract c { // compileViaYul: also // ---- // test() -> 20, 10 -// gas irOptimized: 374254 +// gas irOptimized: 369920 // gas legacy: 320859 // gas legacyOptimized: 314681 // storage: empty diff --git a/test/libsolidity/semanticTests/array/pop/byte_array_pop_copy_long.sol b/test/libsolidity/semanticTests/array/pop/byte_array_pop_copy_long.sol index 76ef30302..aac5d64cd 100644 --- a/test/libsolidity/semanticTests/array/pop/byte_array_pop_copy_long.sol +++ b/test/libsolidity/semanticTests/array/pop/byte_array_pop_copy_long.sol @@ -12,6 +12,6 @@ contract c { // compileViaYul: also // ---- // test() -> 0x20, 29, 0x0303030303030303030303030303030303030303030303030303030303000000 -// gas irOptimized: 163879 +// gas irOptimized: 163643 // gas legacy: 245809 // gas legacyOptimized: 242636 diff --git a/test/libsolidity/semanticTests/array/pop/byte_array_pop_long_storage_empty.sol b/test/libsolidity/semanticTests/array/pop/byte_array_pop_long_storage_empty.sol index 349a50c64..892bd7a16 100644 --- a/test/libsolidity/semanticTests/array/pop/byte_array_pop_long_storage_empty.sol +++ b/test/libsolidity/semanticTests/array/pop/byte_array_pop_long_storage_empty.sol @@ -18,7 +18,7 @@ contract c { // compileViaYul: also // ---- // test() -> true -// gas irOptimized: 460283 +// gas irOptimized: 455964 // gas legacy: 552064 // gas legacyOptimized: 533164 // storage: empty diff --git a/test/libsolidity/semanticTests/array/pop/byte_array_pop_long_storage_empty_garbage_ref.sol b/test/libsolidity/semanticTests/array/pop/byte_array_pop_long_storage_empty_garbage_ref.sol index f9d1b6708..68d9cc091 100644 --- a/test/libsolidity/semanticTests/array/pop/byte_array_pop_long_storage_empty_garbage_ref.sol +++ b/test/libsolidity/semanticTests/array/pop/byte_array_pop_long_storage_empty_garbage_ref.sol @@ -17,7 +17,7 @@ contract c { // compileViaYul: also // ---- // test() -> -// gas irOptimized: 302142 +// gas irOptimized: 300920 // gas legacy: 372763 // gas legacyOptimized: 366846 // storage: empty diff --git a/test/libsolidity/semanticTests/array/pop/byte_array_pop_masking_long.sol b/test/libsolidity/semanticTests/array/pop/byte_array_pop_masking_long.sol index e0206365d..e1dd3edec 100644 --- a/test/libsolidity/semanticTests/array/pop/byte_array_pop_masking_long.sol +++ b/test/libsolidity/semanticTests/array/pop/byte_array_pop_masking_long.sol @@ -12,6 +12,6 @@ contract c { // compileViaYul: also // ---- // test() -> 0x20, 33, 0x303030303030303030303030303030303030303030303030303030303030303, 0x0300000000000000000000000000000000000000000000000000000000000000 -// gas irOptimized: 161236 +// gas irOptimized: 160975 // gas legacy: 243287 // gas legacyOptimized: 240361 diff --git a/test/libsolidity/semanticTests/array/push/array_push.sol b/test/libsolidity/semanticTests/array/push/array_push.sol index 5f66b8437..3595f55ac 100644 --- a/test/libsolidity/semanticTests/array/push/array_push.sol +++ b/test/libsolidity/semanticTests/array/push/array_push.sol @@ -18,6 +18,6 @@ contract c { // compileViaYul: also // ---- // test() -> 5, 4, 3, 3 -// gas irOptimized: 116387 +// gas irOptimized: 111041 // gas legacy: 111938 // gas legacyOptimized: 110528 diff --git a/test/libsolidity/semanticTests/array/push/array_push_nested_from_calldata.sol b/test/libsolidity/semanticTests/array/push/array_push_nested_from_calldata.sol index 020466470..425858409 100644 --- a/test/libsolidity/semanticTests/array/push/array_push_nested_from_calldata.sol +++ b/test/libsolidity/semanticTests/array/push/array_push_nested_from_calldata.sol @@ -14,6 +14,6 @@ contract C { // compileViaYul: also // ---- // f(uint120[]): 0x20, 3, 1, 2, 3 -> 1 -// gas irOptimized: 116591 +// gas irOptimized: 116414 // gas legacy: 116886 // gas legacyOptimized: 116699 diff --git a/test/libsolidity/semanticTests/array/push/array_push_packed_array.sol b/test/libsolidity/semanticTests/array/push/array_push_packed_array.sol index c051e93b5..5ddcb5c8e 100644 --- a/test/libsolidity/semanticTests/array/push/array_push_packed_array.sol +++ b/test/libsolidity/semanticTests/array/push/array_push_packed_array.sol @@ -16,6 +16,6 @@ contract c { // compileViaYul: also // ---- // test() -> 1, 2, 3, 4 -// gas irOptimized: 112751 +// gas irOptimized: 112131 // gas legacy: 107098 // gas legacyOptimized: 106362 diff --git a/test/libsolidity/semanticTests/array/push/array_push_struct.sol b/test/libsolidity/semanticTests/array/push/array_push_struct.sol index e13c0e79f..623582a24 100644 --- a/test/libsolidity/semanticTests/array/push/array_push_struct.sol +++ b/test/libsolidity/semanticTests/array/push/array_push_struct.sol @@ -22,6 +22,6 @@ contract c { // compileViaYul: also // ---- // test() -> 2, 3, 4, 5 -// gas irOptimized: 147373 +// gas irOptimized: 146426 // gas legacy: 190684 // gas legacyOptimized: 188256 diff --git a/test/libsolidity/semanticTests/array/push/array_push_struct_from_calldata.sol b/test/libsolidity/semanticTests/array/push/array_push_struct_from_calldata.sol index 7875d2c21..92319bf14 100644 --- a/test/libsolidity/semanticTests/array/push/array_push_struct_from_calldata.sol +++ b/test/libsolidity/semanticTests/array/push/array_push_struct_from_calldata.sol @@ -18,6 +18,6 @@ contract c { // compileViaYul: also // ---- // test((uint16,uint16,uint16[3],uint16[])): 0x20, 2, 3, 0, 0, 4, 0xC0, 4, 0, 0, 5, 0, 0 -> 2, 3, 4, 5 -// gas irOptimized: 148644 +// gas irOptimized: 148261 // gas legacy: 152444 // gas legacyOptimized: 146671 diff --git a/test/libsolidity/semanticTests/array/push/byte_array_push_transition.sol b/test/libsolidity/semanticTests/array/push/byte_array_push_transition.sol index 58aae2aed..5dca942ea 100644 --- a/test/libsolidity/semanticTests/array/push/byte_array_push_transition.sol +++ b/test/libsolidity/semanticTests/array/push/byte_array_push_transition.sol @@ -17,6 +17,6 @@ contract c { // compileViaYul: also // ---- // test() -> 0 -// gas irOptimized: 397892 +// gas irOptimized: 396112 // gas legacy: 565428 // gas legacyOptimized: 552524 diff --git a/test/libsolidity/semanticTests/array/push/push_no_args_2d.sol b/test/libsolidity/semanticTests/array/push/push_no_args_2d.sol index b3ddb2a24..415d071ba 100644 --- a/test/libsolidity/semanticTests/array/push/push_no_args_2d.sol +++ b/test/libsolidity/semanticTests/array/push/push_no_args_2d.sol @@ -29,14 +29,14 @@ contract C { // ---- // l() -> 0 // f(uint256,uint256): 42, 64 -> -// gas irOptimized: 202796 +// gas irOptimized: 202728 // gas legacy: 163034 // gas legacyOptimized: 157045 // l() -> 1 // ll(uint256): 0 -> 43 // a(uint256,uint256): 0, 42 -> 64 // f(uint256,uint256): 84, 128 -> -// gas irOptimized: 299012 +// gas irOptimized: 298944 // gas legacy: 222080 // gas legacyOptimized: 210631 // l() -> 2 diff --git a/test/libsolidity/semanticTests/array/push/push_no_args_bytes.sol b/test/libsolidity/semanticTests/array/push/push_no_args_bytes.sol index f0c6b445b..3633a04b3 100644 --- a/test/libsolidity/semanticTests/array/push/push_no_args_bytes.sol +++ b/test/libsolidity/semanticTests/array/push/push_no_args_bytes.sol @@ -23,7 +23,7 @@ contract C { // ---- // l() -> 0 // g(uint256): 70 -> -// gas irOptimized: 433438 +// gas irOptimized: 428840 // gas legacy: 419791 // gas legacyOptimized: 415408 // l() -> 70 diff --git a/test/libsolidity/semanticTests/array/reusing_memory.sol b/test/libsolidity/semanticTests/array/reusing_memory.sol index 3436065d3..6fa262faa 100644 --- a/test/libsolidity/semanticTests/array/reusing_memory.sol +++ b/test/libsolidity/semanticTests/array/reusing_memory.sol @@ -26,6 +26,6 @@ contract Main { // compileViaYul: also // ---- // f(uint256): 0x34 -> 0x46bddb1178e94d7f2892ff5f366840eb658911794f2c3a44c450aa2c505186c1 -// gas irOptimized: 117287 +// gas irOptimized: 117113 // gas legacy: 127152 // gas legacyOptimized: 113679 diff --git a/test/libsolidity/semanticTests/constructor/arrays_in_constructors.sol b/test/libsolidity/semanticTests/constructor/arrays_in_constructors.sol index fdc97e3fb..b7e55827b 100644 --- a/test/libsolidity/semanticTests/constructor/arrays_in_constructors.sol +++ b/test/libsolidity/semanticTests/constructor/arrays_in_constructors.sol @@ -26,6 +26,6 @@ contract Creator { // compileViaYul: also // ---- // f(uint256,address[]): 7, 0x40, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 -> 7, 8 -// gas irOptimized: 472714 +// gas irOptimized: 479282 // gas legacy: 570900 // gas legacyOptimized: 435524 diff --git a/test/libsolidity/semanticTests/constructor/bytes_in_constructors_packer.sol b/test/libsolidity/semanticTests/constructor/bytes_in_constructors_packer.sol index 4c12ee6aa..73d00e27e 100644 --- a/test/libsolidity/semanticTests/constructor/bytes_in_constructors_packer.sol +++ b/test/libsolidity/semanticTests/constructor/bytes_in_constructors_packer.sol @@ -26,6 +26,6 @@ contract Creator { // compileViaYul: also // ---- // f(uint256,bytes): 7, 0x40, 78, "abcdefghijklmnopqrstuvwxyzabcdef", "ghijklmnopqrstuvwxyzabcdefghijkl", "mnopqrstuvwxyz" -> 7, "h" -// gas irOptimized: 335239 +// gas irOptimized: 341858 // gas legacy: 414850 // gas legacyOptimized: 290278 diff --git a/test/libsolidity/semanticTests/constructor/no_callvalue_check.sol b/test/libsolidity/semanticTests/constructor/no_callvalue_check.sol index 4efebba23..6a334f9fd 100644 --- a/test/libsolidity/semanticTests/constructor/no_callvalue_check.sol +++ b/test/libsolidity/semanticTests/constructor/no_callvalue_check.sol @@ -19,6 +19,6 @@ contract C { // compileViaYul: also // ---- // f(), 2000 ether -> true -// gas irOptimized: 123853 +// gas irOptimized: 123796 // gas legacy: 123226 // gas legacyOptimized: 123092 diff --git a/test/libsolidity/semanticTests/externalContracts/deposit_contract.sol b/test/libsolidity/semanticTests/externalContracts/deposit_contract.sol index 0349df2f4..76816af61 100644 --- a/test/libsolidity/semanticTests/externalContracts/deposit_contract.sol +++ b/test/libsolidity/semanticTests/externalContracts/deposit_contract.sol @@ -178,33 +178,33 @@ contract DepositContract is IDepositContract, ERC165 { // compileViaYul: also // ---- // constructor() -// gas irOptimized: 1813273 +// gas irOptimized: 1828768 // gas legacy: 2558004 -// gas legacyOptimized: 1806764 +// gas legacyOptimized: 1797889 // supportsInterface(bytes4): 0x0 -> 0 // supportsInterface(bytes4): 0xffffffff00000000000000000000000000000000000000000000000000000000 -> false # defined to be false by ERC-165 # // supportsInterface(bytes4): 0x01ffc9a700000000000000000000000000000000000000000000000000000000 -> true # ERC-165 id # // supportsInterface(bytes4): 0x8564090700000000000000000000000000000000000000000000000000000000 -> true # the deposit interface id # // get_deposit_root() -> 0xd70a234731285c6804c2a4f56711ddb8c82c99740f207854891028af34e27e5e -// gas irOptimized: 107525 +// gas irOptimized: 104470 // gas legacy: 128065 // gas legacyOptimized: 100398 // get_deposit_count() -> 0x20, 8, 0 # TODO: check balance and logs after each deposit # // deposit(bytes,bytes,bytes,bytes32), 32 ether: 0 -> FAILURE # Empty input # // get_deposit_root() -> 0xd70a234731285c6804c2a4f56711ddb8c82c99740f207854891028af34e27e5e -// gas irOptimized: 107525 +// gas irOptimized: 104470 // gas legacy: 128065 // gas legacyOptimized: 100398 // get_deposit_count() -> 0x20, 8, 0 // deposit(bytes,bytes,bytes,bytes32), 1 ether: 0x80, 0xe0, 0x120, 0xaa4a8d0b7d9077248630f1a4701ae9764e42271d7f22b7838778411857fd349e, 0x30, 0x933ad9491b62059dd065b560d256d8957a8c402cc6e8d8ee7290ae11e8f73292, 0x67a8811c397529dac52ae1342ba58c9500000000000000000000000000000000, 0x20, 0x00f50428677c60f997aadeab24aabf7fceaef491c96a52b463ae91f95611cf71, 0x60, 0xa29d01cc8c6296a8150e515b5995390ef841dc18948aa3e79be6d7c1851b4cbb, 0x5d6ff49fa70b9c782399506a22a85193151b9b691245cebafd2063012443c132, 0x4b6c36debaedefb7b2d71b0503ffdc00150aaffd42e63358238ec888901738b8 -> # txhash: 0x7085c586686d666e8bb6e9477a0f0b09565b2060a11f1c4209d3a52295033832 # // get_deposit_root() -> 0x2089653123d9c721215120b6db6738ba273bbc5228ac093b1f983badcdc8a438 -// gas irOptimized: 107535 +// gas irOptimized: 104474 // gas legacy: 128075 // gas legacyOptimized: 100411 // get_deposit_count() -> 0x20, 8, 0x0100000000000000000000000000000000000000000000000000000000000000 // deposit(bytes,bytes,bytes,bytes32), 32 ether: 0x80, 0xe0, 0x120, 0xdbd986dc85ceb382708cf90a3500f500f0a393c5ece76963ac3ed72eccd2c301, 0x30, 0xb2ce0f79f90e7b3a113ca5783c65756f96c4b4673c2b5c1eb4efc22280259441, 0x06d601211e8866dc5b50dc48a244dd7c00000000000000000000000000000000, 0x20, 0x00344b6c73f71b11c56aba0d01b7d8ad83559f209d0a4101a515f6ad54c89771, 0x60, 0x945caaf82d18e78c033927d51f452ebcd76524497b91d7a11219cb3db6a1d369, 0x7595fc095ce489e46b2ef129591f2f6d079be4faaf345a02c5eb133c072e7c56, 0x0c6c3617eee66b4b878165c502357d49485326bc6b31bc96873f308c8f19c09d -> # txhash: 0x404d8e109822ce448e68f45216c12cb051b784d068fbe98317ab8e50c58304ac # // get_deposit_root() -> 0x40255975859377d912c53aa853245ebd939bdd2b33a28e084babdcc1ed8238ee -// gas irOptimized: 107535 +// gas irOptimized: 104474 // gas legacy: 128075 // gas legacyOptimized: 100411 // get_deposit_count() -> 0x20, 8, 0x0200000000000000000000000000000000000000000000000000000000000000 diff --git a/test/libsolidity/semanticTests/externalContracts/snark.sol b/test/libsolidity/semanticTests/externalContracts/snark.sol index b3409848f..4ffeed957 100644 --- a/test/libsolidity/semanticTests/externalContracts/snark.sol +++ b/test/libsolidity/semanticTests/externalContracts/snark.sol @@ -296,6 +296,6 @@ contract Test { // g() -> true // pair() -> true // verifyTx() -> true -// gas irOptimized: 145824 +// gas irOptimized: 129963 // gas legacy: 130571 // gas legacyOptimized: 100147 diff --git a/test/libsolidity/semanticTests/functionCall/failed_create.sol b/test/libsolidity/semanticTests/functionCall/failed_create.sol index 8d5017749..d84b2d02b 100644 --- a/test/libsolidity/semanticTests/functionCall/failed_create.sol +++ b/test/libsolidity/semanticTests/functionCall/failed_create.sol @@ -18,7 +18,7 @@ contract C { // compileViaYul: also // ---- // constructor(), 20 wei -// gas irOptimized: 232551 +// gas irOptimized: 265125 // gas legacy: 285485 // gas legacyOptimized: 177957 // f(uint256): 20 -> 1370859564726510389319704988634906228201275401179 @@ -26,7 +26,7 @@ contract C { // f(uint256): 20 -> FAILURE // x() -> 1 // stack(uint256): 1023 -> FAILURE -// gas irOptimized: 835314 +// gas irOptimized: 853785 // gas legacy: 981671 // gas legacyOptimized: 824895 // x() -> 1 diff --git a/test/libsolidity/semanticTests/functionCall/mapping_array_internal_argument.sol b/test/libsolidity/semanticTests/functionCall/mapping_array_internal_argument.sol index 899025ae6..64e319617 100644 --- a/test/libsolidity/semanticTests/functionCall/mapping_array_internal_argument.sol +++ b/test/libsolidity/semanticTests/functionCall/mapping_array_internal_argument.sol @@ -20,7 +20,7 @@ contract test { // compileViaYul: also // ---- // set(uint8,uint8,uint8,uint8,uint8): 1, 21, 22, 42, 43 -> 0, 0, 0, 0 -// gas irOptimized: 110993 +// gas irOptimized: 110073 // gas legacy: 111406 // gas legacyOptimized: 107981 // get(uint8): 1 -> 21, 22, 42, 43 diff --git a/test/libsolidity/semanticTests/functionTypes/store_function.sol b/test/libsolidity/semanticTests/functionTypes/store_function.sol index 60ec452c4..c2cdab11a 100644 --- a/test/libsolidity/semanticTests/functionTypes/store_function.sol +++ b/test/libsolidity/semanticTests/functionTypes/store_function.sol @@ -28,6 +28,6 @@ contract C { // compileViaYul: also // ---- // t() -> 9 -// gas irOptimized: 124896 +// gas irOptimized: 121044 // gas legacy: 161097 // gas legacyOptimized: 111516 diff --git a/test/libsolidity/semanticTests/immutable/multi_creation.sol b/test/libsolidity/semanticTests/immutable/multi_creation.sol index 2186dedbe..8bfda0209 100644 --- a/test/libsolidity/semanticTests/immutable/multi_creation.sol +++ b/test/libsolidity/semanticTests/immutable/multi_creation.sol @@ -29,7 +29,7 @@ contract C { // compileViaYul: also // ---- // f() -> 3, 7, 5 -// gas irOptimized: 133517 +// gas irOptimized: 133434 // gas legacy: 153990 // gas legacyOptimized: 127822 // x() -> 7 diff --git a/test/libsolidity/semanticTests/inheritance/address_overload_resolution.sol b/test/libsolidity/semanticTests/inheritance/address_overload_resolution.sol index 23e4b624d..f1a6df43a 100644 --- a/test/libsolidity/semanticTests/inheritance/address_overload_resolution.sol +++ b/test/libsolidity/semanticTests/inheritance/address_overload_resolution.sol @@ -23,8 +23,8 @@ contract D { // compileViaYul: also // ---- // f() -> 1 -// gas irOptimized: 111246 +// gas irOptimized: 98658 // gas legacy: 114412 // g() -> 5 -// gas irOptimized: 111379 +// gas irOptimized: 98760 // gas legacy: 114872 diff --git a/test/libsolidity/semanticTests/inheritance/inherited_function_calldata_calldata_interface.sol b/test/libsolidity/semanticTests/inheritance/inherited_function_calldata_calldata_interface.sol index b6ff9dca9..45912f194 100644 --- a/test/libsolidity/semanticTests/inheritance/inherited_function_calldata_calldata_interface.sol +++ b/test/libsolidity/semanticTests/inheritance/inherited_function_calldata_calldata_interface.sol @@ -25,5 +25,5 @@ contract B { // compileViaYul: also // ---- // g() -> 42 -// gas irOptimized: 107173 +// gas irOptimized: 102803 // gas legacy: 117797 diff --git a/test/libsolidity/semanticTests/inheritance/inherited_function_calldata_memory_interface.sol b/test/libsolidity/semanticTests/inheritance/inherited_function_calldata_memory_interface.sol index ca6d32536..7e186f54a 100644 --- a/test/libsolidity/semanticTests/inheritance/inherited_function_calldata_memory_interface.sol +++ b/test/libsolidity/semanticTests/inheritance/inherited_function_calldata_memory_interface.sol @@ -25,6 +25,6 @@ contract B { // compileViaYul: also // ---- // g() -> 42 -// gas irOptimized: 127215 +// gas irOptimized: 134269 // gas legacy: 180597 // gas legacyOptimized: 116351 diff --git a/test/libsolidity/semanticTests/interface_inheritance_conversions.sol b/test/libsolidity/semanticTests/interface_inheritance_conversions.sol index 78aff8ede..25d13916e 100644 --- a/test/libsolidity/semanticTests/interface_inheritance_conversions.sol +++ b/test/libsolidity/semanticTests/interface_inheritance_conversions.sol @@ -37,10 +37,10 @@ contract C { // compileViaYul: also // ---- // convertParent() -> 1 -// gas irOptimized: 122356 +// gas irOptimized: 123220 // convertSubA() -> 1, 2 -// gas irOptimized: 124555 +// gas irOptimized: 125366 // gas legacy: 101703 // convertSubB() -> 1, 3 -// gas irOptimized: 124489 +// gas irOptimized: 125300 // gas legacy: 101637 diff --git a/test/libsolidity/semanticTests/salted_create/salted_create.sol b/test/libsolidity/semanticTests/salted_create/salted_create.sol index 9c0e4aa80..52a72dd91 100644 --- a/test/libsolidity/semanticTests/salted_create/salted_create.sol +++ b/test/libsolidity/semanticTests/salted_create/salted_create.sol @@ -22,6 +22,6 @@ contract A { // ---- // different_salt() -> true // same_salt() -> true -// gas irOptimized: 98439083 +// gas irOptimized: 98439037 // gas legacy: 98439116 // gas legacyOptimized: 98438970 diff --git a/test/libsolidity/semanticTests/salted_create/salted_create_with_value.sol b/test/libsolidity/semanticTests/salted_create/salted_create_with_value.sol index 6f9991857..e7f53a1ea 100644 --- a/test/libsolidity/semanticTests/salted_create/salted_create_with_value.sol +++ b/test/libsolidity/semanticTests/salted_create/salted_create_with_value.sol @@ -22,6 +22,6 @@ contract A { // compileViaYul: also // ---- // f(), 10 ether -> 3007, 3008, 3009 -// gas irOptimized: 338630 +// gas irOptimized: 327566 // gas legacy: 422027 // gas legacyOptimized: 287256 diff --git a/test/libsolidity/semanticTests/storage/packed_storage_structs_bytes.sol b/test/libsolidity/semanticTests/storage/packed_storage_structs_bytes.sol index 9084a41ab..4de6cc86c 100644 --- a/test/libsolidity/semanticTests/storage/packed_storage_structs_bytes.sol +++ b/test/libsolidity/semanticTests/storage/packed_storage_structs_bytes.sol @@ -46,6 +46,6 @@ contract C { // compileViaYul: also // ---- // test() -> true -// gas irOptimized: 143682 +// gas irOptimized: 143351 // gas legacy: 143536 // gas legacyOptimized: 133280 diff --git a/test/libsolidity/semanticTests/structs/calldata/calldata_struct_with_nested_array_to_storage.sol b/test/libsolidity/semanticTests/structs/calldata/calldata_struct_with_nested_array_to_storage.sol index 42a314297..3f400ab28 100644 --- a/test/libsolidity/semanticTests/structs/calldata/calldata_struct_with_nested_array_to_storage.sol +++ b/test/libsolidity/semanticTests/structs/calldata/calldata_struct_with_nested_array_to_storage.sol @@ -18,6 +18,6 @@ contract C { // compileViaYul: also // ---- // f(uint32,(uint128,uint256[][2],uint32)): 55, 0x40, 77, 0x60, 88, 0x40, 0x40, 2, 1, 2 -> 55, 77, 1, 2, 88 -// gas irOptimized: 202389 +// gas irOptimized: 198007 // gas legacy: 205149 -// gas legacyOptimized: 200512 +// gas legacyOptimized: 196983 diff --git a/test/libsolidity/semanticTests/structs/conversion/recursive_storage_memory.sol b/test/libsolidity/semanticTests/structs/conversion/recursive_storage_memory.sol index 873cb5dff..84c8b6c14 100644 --- a/test/libsolidity/semanticTests/structs/conversion/recursive_storage_memory.sol +++ b/test/libsolidity/semanticTests/structs/conversion/recursive_storage_memory.sol @@ -25,4 +25,4 @@ contract CopyTest { // compileViaYul: also // ---- // run() -> 2, 23, 42 -// gas irOptimized: 114638 +// gas irOptimized: 110109 diff --git a/test/libsolidity/semanticTests/structs/memory_structs_nested_load.sol b/test/libsolidity/semanticTests/structs/memory_structs_nested_load.sol index efff72da3..aa681bae3 100644 --- a/test/libsolidity/semanticTests/structs/memory_structs_nested_load.sol +++ b/test/libsolidity/semanticTests/structs/memory_structs_nested_load.sol @@ -68,7 +68,7 @@ contract Test { // compileViaYul: also // ---- // load() -> 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 -// gas irOptimized: 112329 +// gas irOptimized: 111603 // gas legacy: 113999 // gas legacyOptimized: 106281 // store() -> 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 diff --git a/test/libsolidity/semanticTests/structs/struct_containing_bytes_copy_and_delete.sol b/test/libsolidity/semanticTests/structs/struct_containing_bytes_copy_and_delete.sol index 807e8ad6a..7ac2f3f4a 100644 --- a/test/libsolidity/semanticTests/structs/struct_containing_bytes_copy_and_delete.sol +++ b/test/libsolidity/semanticTests/structs/struct_containing_bytes_copy_and_delete.sol @@ -25,7 +25,7 @@ contract c { // ---- // storage: empty // set(uint256,bytes,uint256): 12, 0x60, 13, 33, "12345678901234567890123456789012", "3" -> true -// gas irOptimized: 124416 +// gas irOptimized: 124337 // gas legacy: 124736 // gas legacyOptimized: 124179 // test(uint256): 32 -> "3" diff --git a/test/libsolidity/semanticTests/structs/struct_copy.sol b/test/libsolidity/semanticTests/structs/struct_copy.sol index c5a743382..1215407c0 100644 --- a/test/libsolidity/semanticTests/structs/struct_copy.sol +++ b/test/libsolidity/semanticTests/structs/struct_copy.sol @@ -38,12 +38,12 @@ contract c { // compileViaYul: also // ---- // set(uint256): 7 -> true -// gas irOptimized: 101963 +// gas irOptimized: 101915 // gas legacy: 102216 // gas legacyOptimized: 101606 // retrieve(uint256): 7 -> 1, 3, 4, 2 // copy(uint256,uint256): 7, 8 -> true -// gas irOptimized: 105289 +// gas irOptimized: 105232 // gas legacy: 105566 // gas legacyOptimized: 105022 // retrieve(uint256): 7 -> 1, 3, 4, 2 diff --git a/test/libsolidity/semanticTests/structs/struct_copy_via_local.sol b/test/libsolidity/semanticTests/structs/struct_copy_via_local.sol index cb2efa54b..c60821a09 100644 --- a/test/libsolidity/semanticTests/structs/struct_copy_via_local.sol +++ b/test/libsolidity/semanticTests/structs/struct_copy_via_local.sol @@ -21,6 +21,6 @@ contract c { // compileViaYul: also // ---- // test() -> true -// gas irOptimized: 101589 +// gas irOptimized: 101509 // gas legacy: 106427 // gas legacyOptimized: 101306 diff --git a/test/libsolidity/semanticTests/structs/struct_delete_storage_nested_small.sol b/test/libsolidity/semanticTests/structs/struct_delete_storage_nested_small.sol index 86ed9512d..e23957373 100644 --- a/test/libsolidity/semanticTests/structs/struct_delete_storage_nested_small.sol +++ b/test/libsolidity/semanticTests/structs/struct_delete_storage_nested_small.sol @@ -33,4 +33,4 @@ contract C { // compileViaYul: true // ---- // f() -> 0, 0, 0 -// gas irOptimized: 125239 +// gas irOptimized: 124791 diff --git a/test/libsolidity/semanticTests/structs/struct_delete_storage_with_array.sol b/test/libsolidity/semanticTests/structs/struct_delete_storage_with_array.sol index f9203556c..acd34851f 100644 --- a/test/libsolidity/semanticTests/structs/struct_delete_storage_with_array.sol +++ b/test/libsolidity/semanticTests/structs/struct_delete_storage_with_array.sol @@ -44,7 +44,7 @@ contract C { // compileViaYul: also // ---- // f() -> -// gas irOptimized: 129594 +// gas irOptimized: 124107 // gas legacy: 126832 // gas legacyOptimized: 125500 // g() -> diff --git a/test/libsolidity/semanticTests/structs/struct_delete_storage_with_arrays_small.sol b/test/libsolidity/semanticTests/structs/struct_delete_storage_with_arrays_small.sol index 3eb7bd3de..411839713 100644 --- a/test/libsolidity/semanticTests/structs/struct_delete_storage_with_arrays_small.sol +++ b/test/libsolidity/semanticTests/structs/struct_delete_storage_with_arrays_small.sol @@ -27,4 +27,4 @@ contract C { // compileViaYul: true // ---- // f() -> 0 -// gas irOptimized: 118846 +// gas irOptimized: 118118 diff --git a/test/libsolidity/semanticTests/structs/struct_memory_to_storage_function_ptr.sol b/test/libsolidity/semanticTests/structs/struct_memory_to_storage_function_ptr.sol index f95d56e0c..5d2c3a381 100644 --- a/test/libsolidity/semanticTests/structs/struct_memory_to_storage_function_ptr.sol +++ b/test/libsolidity/semanticTests/structs/struct_memory_to_storage_function_ptr.sol @@ -31,6 +31,6 @@ contract C { // compileViaYul: also // ---- // f() -> 42, 23, 34, 42, 42 -// gas irOptimized: 108820 +// gas irOptimized: 108681 // gas legacy: 110821 // gas legacyOptimized: 105148 diff --git a/test/libsolidity/semanticTests/structs/structs.sol b/test/libsolidity/semanticTests/structs/structs.sol index b8b7de3b8..eeab27ade 100644 --- a/test/libsolidity/semanticTests/structs/structs.sol +++ b/test/libsolidity/semanticTests/structs/structs.sol @@ -32,7 +32,7 @@ contract test { // ---- // check() -> false // set() -> -// gas irOptimized: 128686 +// gas irOptimized: 128533 // gas legacy: 129577 // gas legacyOptimized: 126964 // check() -> true diff --git a/test/libsolidity/semanticTests/various/destructuring_assignment.sol b/test/libsolidity/semanticTests/various/destructuring_assignment.sol index 055a635f8..d2a0cfc3a 100644 --- a/test/libsolidity/semanticTests/various/destructuring_assignment.sol +++ b/test/libsolidity/semanticTests/various/destructuring_assignment.sol @@ -36,6 +36,6 @@ contract C { // compileViaYul: also // ---- // f(bytes): 0x20, 0x5, "abcde" -> 0 -// gas irOptimized: 248997 +// gas irOptimized: 242046 // gas legacy: 239258 // gas legacyOptimized: 238577 diff --git a/test/libsolidity/semanticTests/various/skip_dynamic_types_for_structs.sol b/test/libsolidity/semanticTests/various/skip_dynamic_types_for_structs.sol index 05e8fd9bc..668d24880 100644 --- a/test/libsolidity/semanticTests/various/skip_dynamic_types_for_structs.sol +++ b/test/libsolidity/semanticTests/various/skip_dynamic_types_for_structs.sol @@ -22,6 +22,6 @@ contract C { // compileViaYul: also // ---- // g() -> 2, 6 -// gas irOptimized: 170422 +// gas irOptimized: 169985 // gas legacy: 172490 // gas legacyOptimized: 171209 diff --git a/test/libsolidity/semanticTests/various/swap_in_storage_overwrite.sol b/test/libsolidity/semanticTests/various/swap_in_storage_overwrite.sol index 28e214983..a3e070400 100644 --- a/test/libsolidity/semanticTests/various/swap_in_storage_overwrite.sol +++ b/test/libsolidity/semanticTests/various/swap_in_storage_overwrite.sol @@ -30,7 +30,7 @@ contract c { // x() -> 0, 0 // y() -> 0, 0 // set() -> -// gas irOptimized: 101473 +// gas irOptimized: 101425 // gas legacy: 101332 // gas legacyOptimized: 101282 // x() -> 1, 2 diff --git a/test/libsolidity/semanticTests/viaYul/array_memory_index_access.sol b/test/libsolidity/semanticTests/viaYul/array_memory_index_access.sol index 95efccecc..464ed1bd1 100644 --- a/test/libsolidity/semanticTests/viaYul/array_memory_index_access.sol +++ b/test/libsolidity/semanticTests/viaYul/array_memory_index_access.sol @@ -28,7 +28,7 @@ contract C { // index(uint256): 10 -> true // index(uint256): 20 -> true // index(uint256): 0xFF -> true -// gas irOptimized: 167533 +// gas irOptimized: 167453 // gas legacy: 248854 // gas legacyOptimized: 152638 // accessIndex(uint256,int256): 10, 1 -> 2 diff --git a/test/libsolidity/semanticTests/viaYul/array_storage_index_access.sol b/test/libsolidity/semanticTests/viaYul/array_storage_index_access.sol index 0df1d245e..682156a4b 100644 --- a/test/libsolidity/semanticTests/viaYul/array_storage_index_access.sol +++ b/test/libsolidity/semanticTests/viaYul/array_storage_index_access.sol @@ -18,33 +18,33 @@ contract C { // ---- // test_indices(uint256): 1 -> // test_indices(uint256): 129 -> -// gas irOptimized: 3571897 +// gas irOptimized: 3566833 // gas legacy: 3340105 // gas legacyOptimized: 3280773 // test_indices(uint256): 5 -> -// gas irOptimized: 684425 +// gas irOptimized: 474317 // gas legacy: 458941 // gas legacyOptimized: 455849 // test_indices(uint256): 10 -> // test_indices(uint256): 15 -> -// gas irOptimized: 115282 +// gas irOptimized: 114781 // test_indices(uint256): 0xFF -> -// gas irOptimized: 4553257 +// gas irOptimized: 4543461 // gas legacy: 4107867 // gas legacyOptimized: 3991807 // test_indices(uint256): 1000 -> -// gas irOptimized: 21913394 +// gas irOptimized: 21877663 // gas legacy: 20360399 // gas legacyOptimized: 19921344 // test_indices(uint256): 129 -> -// gas irOptimized: 5133069 +// gas irOptimized: 3655066 // gas legacy: 3472135 // gas legacyOptimized: 3415947 // test_indices(uint256): 128 -> -// gas irOptimized: 663269 +// gas irOptimized: 658202 // gas legacy: 556972 // gas legacyOptimized: 508124 // test_indices(uint256): 1 -> -// gas irOptimized: 679981 +// gas irOptimized: 464898 // gas legacy: 452407 // gas legacyOptimized: 450811 diff --git a/test/libsolidity/semanticTests/viaYul/array_storage_index_boundary_test.sol b/test/libsolidity/semanticTests/viaYul/array_storage_index_boundary_test.sol index e2992eede..556732d62 100644 --- a/test/libsolidity/semanticTests/viaYul/array_storage_index_boundary_test.sol +++ b/test/libsolidity/semanticTests/viaYul/array_storage_index_boundary_test.sol @@ -18,11 +18,11 @@ contract C { // test_boundary_check(uint256,uint256): 1, 1 -> FAILURE, hex"4e487b71", 0x32 // test_boundary_check(uint256,uint256): 10, 10 -> FAILURE, hex"4e487b71", 0x32 // test_boundary_check(uint256,uint256): 256, 256 -> FAILURE, hex"4e487b71", 0x32 -// gas irOptimized: 678468 +// gas irOptimized: 676497 // gas legacy: 648515 // gas legacyOptimized: 628739 // test_boundary_check(uint256,uint256): 256, 255 -> 0 -// gas irOptimized: 679608 +// gas irOptimized: 677586 // gas legacy: 649549 // gas legacyOptimized: 629633 // test_boundary_check(uint256,uint256): 256, 0xFFFF -> FAILURE, hex"4e487b71", 0x32 diff --git a/test/libsolidity/semanticTests/viaYul/array_storage_index_zeroed_test.sol b/test/libsolidity/semanticTests/viaYul/array_storage_index_zeroed_test.sol index debdee5cf..9ebdbdfa4 100644 --- a/test/libsolidity/semanticTests/viaYul/array_storage_index_zeroed_test.sol +++ b/test/libsolidity/semanticTests/viaYul/array_storage_index_zeroed_test.sol @@ -54,18 +54,18 @@ contract C { // ---- // test_zeroed_indicies(uint256): 1 -> // test_zeroed_indicies(uint256): 5 -> -// gas irOptimized: 222579 +// gas irOptimized: 208688 // gas legacy: 191267 // gas legacyOptimized: 188486 // test_zeroed_indicies(uint256): 10 -> -// gas irOptimized: 327289 +// gas irOptimized: 304710 // gas legacy: 276129 // gas legacyOptimized: 271024 // test_zeroed_indicies(uint256): 15 -> -// gas irOptimized: 409274 +// gas irOptimized: 378020 // gas legacy: 339254 // gas legacyOptimized: 331904 // test_zeroed_indicies(uint256): 0xFF -> -// gas irOptimized: 9684929 +// gas irOptimized: 9234220 // gas legacy: 8477449 // gas legacyOptimized: 8343774 diff --git a/test/libsolidity/semanticTests/viaYul/array_storage_length_access.sol b/test/libsolidity/semanticTests/viaYul/array_storage_length_access.sol index 5ddd3955f..fb704f321 100644 --- a/test/libsolidity/semanticTests/viaYul/array_storage_length_access.sol +++ b/test/libsolidity/semanticTests/viaYul/array_storage_length_access.sol @@ -14,11 +14,11 @@ contract C { // set_get_length(uint256): 10 -> 10 // set_get_length(uint256): 20 -> 20 // set_get_length(uint256): 0xFF -> 0xFF -// gas irOptimized: 434473 +// gas irOptimized: 434427 // gas legacy: 619622 // gas legacyOptimized: 600718 // set_get_length(uint256): 0xFFF -> 0xFFF -// gas irOptimized: 6743235 +// gas irOptimized: 6743189 // gas legacy: 9765519 // gas legacyOptimized: 9461820 // set_get_length(uint256): 0xFFFFF -> FAILURE # Out-of-gas # diff --git a/test/libsolidity/semanticTests/viaYul/array_storage_push_empty.sol b/test/libsolidity/semanticTests/viaYul/array_storage_push_empty.sol index 9dc970435..3c99e10fa 100644 --- a/test/libsolidity/semanticTests/viaYul/array_storage_push_empty.sol +++ b/test/libsolidity/semanticTests/viaYul/array_storage_push_empty.sol @@ -13,11 +13,11 @@ contract C { // compileViaYul: also // ---- // pushEmpty(uint256): 128 -// gas irOptimized: 631781 +// gas irOptimized: 629687 // gas legacy: 607287 // gas legacyOptimized: 589048 // pushEmpty(uint256): 256 -// gas irOptimized: 862309 +// gas irOptimized: 859191 // gas legacy: 828983 // gas legacyOptimized: 802808 // pushEmpty(uint256): 32768 -> FAILURE # out-of-gas # diff --git a/test/libsolidity/semanticTests/viaYul/array_storage_push_empty_length_address.sol b/test/libsolidity/semanticTests/viaYul/array_storage_push_empty_length_address.sol index 2a92def82..a826856f9 100644 --- a/test/libsolidity/semanticTests/viaYul/array_storage_push_empty_length_address.sol +++ b/test/libsolidity/semanticTests/viaYul/array_storage_push_empty_length_address.sol @@ -18,15 +18,15 @@ contract C { // set_get_length(uint256): 10 -> 10 // set_get_length(uint256): 20 -> 20 // set_get_length(uint256): 0 -> 0 -// gas irOptimized: 110256 +// gas irOptimized: 110050 // gas legacy: 107830 // gas legacyOptimized: 107262 // set_get_length(uint256): 0xFF -> 0xFF -// gas irOptimized: 702388 +// gas irOptimized: 700302 // gas legacy: 882337 // gas legacyOptimized: 650704 // set_get_length(uint256): 0xFFF -> 0xFFF -// gas irOptimized: 10238500 +// gas irOptimized: 10207734 // gas legacy: 12945874 // gas legacyOptimized: 9462646 // set_get_length(uint256): 0xFFFF -> FAILURE # Out-of-gas # diff --git a/test/libsolidity/semanticTests/viaYul/array_storage_push_pop.sol b/test/libsolidity/semanticTests/viaYul/array_storage_push_pop.sol index c7b9994a5..5c0e94df9 100644 --- a/test/libsolidity/semanticTests/viaYul/array_storage_push_pop.sol +++ b/test/libsolidity/semanticTests/viaYul/array_storage_push_pop.sol @@ -15,15 +15,15 @@ contract C { // set_get_length(uint256): 1 -> 0 // set_get_length(uint256): 10 -> 0 // set_get_length(uint256): 20 -> 0 -// gas irOptimized: 162739 +// gas irOptimized: 162373 // gas legacy: 141922 // gas legacyOptimized: 139708 // set_get_length(uint256): 0xFF -> 0 -// gas irOptimized: 1791994 +// gas irOptimized: 1787868 // gas legacy: 1524427 // gas legacyOptimized: 1500358 // set_get_length(uint256): 0xFFF -> 0 -// gas irOptimized: 28414726 +// gas irOptimized: 28349160 // gas legacy: 24115159 // gas legacyOptimized: 23733970 // set_get_length(uint256): 0xFFFF -> FAILURE # Out-of-gas # diff --git a/test/libyul/YulOptimizerTestCommon.cpp b/test/libyul/YulOptimizerTestCommon.cpp index c8305eaa2..2f8334eef 100644 --- a/test/libyul/YulOptimizerTestCommon.cpp +++ b/test/libyul/YulOptimizerTestCommon.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -151,6 +152,11 @@ YulOptimizerTestCommon::YulOptimizerTestCommon( disambiguate(); FunctionHoister::run(*m_context, *m_ast); }}, + {"functionSpecializer", [&]() { + disambiguate(); + FunctionHoister::run(*m_context, *m_object->code); + FunctionSpecializer::run(*m_context, *m_object->code); + }}, {"expressionInliner", [&]() { disambiguate(); ExpressionInliner::run(*m_context, *m_ast); diff --git a/test/libyul/yulOptimizerTests/fullSuite/abi_example1.yul b/test/libyul/yulOptimizerTests/fullSuite/abi_example1.yul index 8e47a4afa..7934c39fd 100644 --- a/test/libyul/yulOptimizerTests/fullSuite/abi_example1.yul +++ b/test/libyul/yulOptimizerTests/fullSuite/abi_example1.yul @@ -507,12 +507,11 @@ // for { } lt(i, length) { i := add(i, 1) } // { // if iszero(slt(add(src, _1), end)) { revert(0, 0) } -// let _3 := 64 -// let dst_1 := allocateMemory(_3) +// let dst_1 := allocateMemory_967() // let dst_2 := dst_1 // let src_1 := src -// let _4 := add(src, _3) -// if gt(_4, end) { revert(0, 0) } +// let _3 := add(src, 64) +// if gt(_3, end) { revert(0, 0) } // let i_1 := 0 // for { } lt(i_1, 0x2) { i_1 := add(i_1, 1) } // { @@ -522,7 +521,7 @@ // } // mstore(dst, dst_2) // dst := add(dst, _2) -// src := _4 +// src := _3 // } // } // function abi_decode_uint256t_uint256t_array_uint256_dynt_array_array_uint256_memory_dyn(headStart, dataEnd) -> value0, value1, value2, value3 @@ -555,6 +554,13 @@ // if gt(offset_1, _2) { revert(value3, value3) } // value3 := abi_decode_array_array_uint256_memory_dyn(add(headStart, offset_1), dataEnd) // } +// function allocateMemory_967() -> memPtr +// { +// memPtr := mload(64) +// let newFreePtr := add(memPtr, 64) +// if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr)) { revert(0, 0) } +// mstore(64, newFreePtr) +// } // function allocateMemory(size) -> memPtr // { // memPtr := mload(64) diff --git a/test/libyul/yulOptimizerTests/fullSuite/ackermann_function.yul b/test/libyul/yulOptimizerTests/fullSuite/ackermann_function.yul new file mode 100644 index 000000000..dd5facaf0 --- /dev/null +++ b/test/libyul/yulOptimizerTests/fullSuite/ackermann_function.yul @@ -0,0 +1,44 @@ +// https://en.wikipedia.org/wiki/Ackermann_function +// Test to see how FunctionSpecializer deals with functions that are too recursive / resource intensive. +{ + // 5 + sstore(0, A(2, 1)) + // 7 + sstore(1, A(2, 2)) + + // Too many unrolling needed. In arbitrary precision, the value is 2**65536 - 3. + sstore(2, A(4, 2)) + + function A(m, n) -> ret { + switch m + case 0 { ret := add(n, 1) } + default { + switch n + case 0 { ret := A(sub(m, 1), 1) } + default { ret := A(sub(m, 1), A(m, sub(n, 1))) } + } + } +} +// ---- +// step: fullSuite +// +// { +// { +// sstore(0, A(2, 1)) +// sstore(1, A(2, 2)) +// sstore(2, A(4, 2)) +// } +// function A(m, n) -> ret +// { +// switch m +// case 0 { ret := add(n, 1) } +// default { +// switch n +// case 0 { ret := A(add(m, not(0)), 1) } +// default { +// let _1 := not(0) +// ret := A(add(m, _1), A(m, add(n, _1))) +// } +// } +// } +// } diff --git a/test/libyul/yulOptimizerTests/fullSuite/ackermann_function_if.yul b/test/libyul/yulOptimizerTests/fullSuite/ackermann_function_if.yul new file mode 100644 index 000000000..005c58778 --- /dev/null +++ b/test/libyul/yulOptimizerTests/fullSuite/ackermann_function_if.yul @@ -0,0 +1,51 @@ +// https://en.wikipedia.org/wiki/Ackermann_function +// Test to see how FunctionSpecializer deals with functions that are too recursive / resource intensive. +// Unlike the test ackermann_function.yul, this one implements it using `if` and leave +{ + // 5 + sstore(0, A(2, 1)) + // 7 + sstore(1, A(2, 2)) + + // Too many unrolling needed. In arbitrary precision, the value is 2**65536 - 3. + sstore(2, A(4, 2)) + + function A(m, n) -> ret { + if eq(m, 0) { + ret := add(n, 1) + leave + } + + if eq(n, 0) { + ret := A(sub(m, 1), 1) + leave + } + + ret := A(sub(m, 1), A(m, sub(n, 1))) + } +} +// ---- +// step: fullSuite +// +// { +// { +// sstore(0, A(2, 1)) +// sstore(1, A(2, 2)) +// sstore(2, A(4, 2)) +// } +// function A(m, n) -> ret +// { +// if iszero(m) +// { +// ret := add(n, 1) +// leave +// } +// if iszero(n) +// { +// ret := A(add(m, not(0)), 1) +// leave +// } +// let _1 := not(0) +// ret := A(add(m, _1), A(m, add(n, _1))) +// } +// } diff --git a/test/libyul/yulOptimizerTests/fullSuite/aztec.yul b/test/libyul/yulOptimizerTests/fullSuite/aztec.yul index 56a046c76..68640c7ca 100644 --- a/test/libyul/yulOptimizerTests/fullSuite/aztec.yul +++ b/test/libyul/yulOptimizerTests/fullSuite/aztec.yul @@ -284,17 +284,15 @@ // let _5 := 0x40 // calldatacopy(0xe0, add(_3, 164), _5) // calldatacopy(0x20, add(_3, 100), _5) -// let _6 := 0x120 -// mstore(_6, sub(_2, c)) -// let _7 := 0x60 -// mstore(_7, k) +// mstore(0x120, sub(_2, c)) +// mstore(0x60, k) // mstore(0xc0, a) -// let result := call(gas(), 7, 0, 0xe0, _7, 0x1a0, _5) -// let result_1 := and(result, call(gas(), 7, 0, 0x20, _7, _6, _5)) -// let _8 := 0x160 -// let result_2 := and(result_1, call(gas(), 7, 0, 0x80, _7, _8, _5)) -// let result_3 := and(result_2, call(gas(), 6, 0, _6, 0x80, _8, _5)) -// result := and(result_3, call(gas(), 6, 0, _8, 0x80, b, _5)) +// let result := call(gas(), 7, 0, 0xe0, 0x60, 0x1a0, _5) +// let result_1 := and(result, call(gas(), 7, 0, 0x20, 0x60, 0x120, _5)) +// let _6 := 0x160 +// let result_2 := and(result_1, call(gas(), 7, 0, 0x80, 0x60, _6, _5)) +// let result_3 := and(result_2, call(gas(), 6, 0, 0x120, 0x80, _6, _5)) +// result := and(result_3, call(gas(), 6, 0, _6, 0x80, b, _5)) // if eq(i, m) // { // mstore(0x260, mload(0x20)) @@ -304,8 +302,8 @@ // } // if gt(i, m) // { -// mstore(_7, c) -// let result_4 := and(result, call(gas(), 7, 0, 0x20, _7, 0x220, _5)) +// mstore(0x60, c) +// let result_4 := and(result, call(gas(), 7, 0, 0x20, 0x60, 0x220, _5)) // let result_5 := and(result_4, call(gas(), 6, 0, 0x220, 0x80, 0x260, _5)) // result := and(result_5, call(gas(), 6, 0, 0x1a0, 0x80, 0x1e0, _5)) // } @@ -316,7 +314,7 @@ // } // b := add(b, _5) // } -// if lt(m, n) { validatePairing(100) } +// if lt(m, n) { validatePairing() } // if iszero(eq(mod(keccak256(0x2a0, add(b, not(671))), _2), challenge)) // { // mstore(0, 404) @@ -325,40 +323,41 @@ // mstore(0, 0x01) // return(0, 0x20) // } -// function validatePairing(t2) +// function validatePairing() // { -// let t2_x := calldataload(t2) -// let _1 := 0x20 -// let t2_x_1 := calldataload(add(t2, _1)) -// let t2_y := calldataload(add(t2, 0x40)) -// let t2_y_1 := calldataload(add(t2, 0x60)) -// let _2 := 0x90689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b -// let _3 := 0x12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa -// let _4 := 0x198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c2 -// let _5 := 0x1800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed -// if or(or(or(or(or(or(or(iszero(t2_x), iszero(t2_x_1)), iszero(t2_y)), iszero(t2_y_1)), eq(t2_x, _5)), eq(t2_x_1, _4)), eq(t2_y, _3)), eq(t2_y_1, _2)) +// let t2_x := calldataload(0x64) +// let t2_x_1 := calldataload(132) +// let t2_y := calldataload(164) +// let t2_y_1 := calldataload(196) +// let _1 := 0x90689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b +// let _2 := 0x12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa +// let _3 := 0x198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c2 +// let _4 := 0x1800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed +// if or(or(or(or(or(or(or(iszero(t2_x), iszero(t2_x_1)), iszero(t2_y)), iszero(t2_y_1)), eq(t2_x, _4)), eq(t2_x_1, _3)), eq(t2_y, _2)), eq(t2_y_1, _1)) // { // mstore(0x00, 400) -// revert(0x00, _1) +// revert(0x00, 0x20) // } -// mstore(_1, mload(0x1e0)) +// let _5 := mload(0x1e0) +// let _6 := 0x20 +// mstore(_6, _5) // mstore(0x40, mload(0x200)) -// mstore(0x80, _5) -// mstore(0x60, _4) -// mstore(0xc0, _3) -// mstore(0xa0, _2) +// mstore(0x80, _4) +// mstore(0x60, _3) +// mstore(0xc0, _2) +// mstore(0xa0, _1) // mstore(0xe0, mload(0x260)) // mstore(0x100, mload(0x280)) // mstore(0x140, t2_x) // mstore(0x120, t2_x_1) -// let _6 := 0x180 -// mstore(_6, t2_y) +// let _7 := 0x180 +// mstore(_7, t2_y) // mstore(0x160, t2_y_1) -// let success := call(gas(), 8, 0, _1, _6, _1, _1) -// if or(iszero(success), iszero(mload(_1))) +// let success := call(gas(), 8, 0, _6, _7, _6, _6) +// if or(iszero(success), iszero(mload(_6))) // { // mstore(0, 400) -// revert(0, _1) +// revert(0, _6) // } // } // function validateCommitment(note, k, a) diff --git a/test/libyul/yulOptimizerTests/fullSuite/fibonacci.yul b/test/libyul/yulOptimizerTests/fullSuite/fibonacci.yul new file mode 100644 index 000000000..479bd5f8b --- /dev/null +++ b/test/libyul/yulOptimizerTests/fullSuite/fibonacci.yul @@ -0,0 +1,47 @@ +{ + sstore(0, fib(0)) + sstore(1, fib(2)) + sstore(2, fib(3)) + sstore(3, fib(4)) + sstore(4, fib(5)) + sstore(5, fib(6)) + sstore(7, fib(7)) + sstore(8, fib(8)) + sstore(9, fib(9)) + sstore(10, fib(10)) + + + function fib(i) -> y + { + y := 1 + if gt(i, 2) + { + y := add(fib(sub(i, 1)), fib(sub(i, 2))) + } + } +} +// ---- +// step: fullSuite +// +// { +// { +// sstore(0, fib(0)) +// sstore(1, fib(2)) +// sstore(2, fib(3)) +// sstore(3, fib(4)) +// sstore(4, fib(5)) +// sstore(5, fib(6)) +// sstore(7, fib(7)) +// sstore(8, fib(8)) +// sstore(9, fib(9)) +// sstore(10, fib(10)) +// } +// function fib(i) -> y +// { +// y := 1 +// if gt(i, 2) +// { +// y := add(fib(add(i, not(0))), fib(add(i, not(1)))) +// } +// } +// } diff --git a/test/libyul/yulOptimizerTests/functionSpecializer/multiple.yul b/test/libyul/yulOptimizerTests/functionSpecializer/multiple.yul new file mode 100644 index 000000000..d4df40537 --- /dev/null +++ b/test/libyul/yulOptimizerTests/functionSpecializer/multiple.yul @@ -0,0 +1,35 @@ +{ + f(1, 2) + + let x := 1 + f(x, 2) + + f(calldataload(0), calldataload(1)) + + function f(a, b) { + sstore(a, b) + } + +} +// ---- +// step: functionSpecializer +// +// { +// f_1() +// let x := 1 +// f_2(x) +// f(calldataload(0), calldataload(1)) +// function f_1() +// { +// let a_4 := 1 +// let b_3 := 2 +// sstore(a_4, b_3) +// } +// function f_2(a_6) +// { +// let b_5 := 2 +// sstore(a_6, b_5) +// } +// function f(a, b) +// { sstore(a, b) } +// } diff --git a/test/libyul/yulOptimizerTests/functionSpecializer/partial.yul b/test/libyul/yulOptimizerTests/functionSpecializer/partial.yul new file mode 100644 index 000000000..6b18da019 --- /dev/null +++ b/test/libyul/yulOptimizerTests/functionSpecializer/partial.yul @@ -0,0 +1,33 @@ +{ + // All arguments are constants + let x := 2 + f(1, x, 3) + + function f(a, b, c) { + sstore(a, b) + sstore(b, c) + // Prevents getting inlined + if calldataload(0) { leave } + } +} +// ---- +// step: functionSpecializer +// +// { +// let x := 2 +// f_1(x) +// function f_1(b_3) +// { +// let a_4 := 1 +// let c_2 := 3 +// sstore(a_4, b_3) +// sstore(b_3, c_2) +// if calldataload(0) { leave } +// } +// function f(a, b, c) +// { +// sstore(a, b) +// sstore(b, c) +// if calldataload(0) { leave } +// } +// } diff --git a/test/libyul/yulOptimizerTests/functionSpecializer/recursion.yul b/test/libyul/yulOptimizerTests/functionSpecializer/recursion.yul new file mode 100644 index 000000000..5cbc70236 --- /dev/null +++ b/test/libyul/yulOptimizerTests/functionSpecializer/recursion.yul @@ -0,0 +1,25 @@ +{ + sstore(0, fib(8)) + function fib(i) -> y + { + y := 1 + if gt(i, 2) + { + y := add(fib(sub(i, 1)), fib(sub(i, 2))) + } + } +} +// ---- +// step: functionSpecializer +// +// { +// sstore(0, fib(8)) +// function fib(i) -> y +// { +// y := 1 +// if gt(i, 2) +// { +// y := add(fib(sub(i, 1)), fib(sub(i, 2))) +// } +// } +// } diff --git a/test/libyul/yulOptimizerTests/functionSpecializer/simple.yul b/test/libyul/yulOptimizerTests/functionSpecializer/simple.yul new file mode 100644 index 000000000..3ec298ebd --- /dev/null +++ b/test/libyul/yulOptimizerTests/functionSpecializer/simple.yul @@ -0,0 +1,28 @@ +{ + // All arguments are constants + f(1, 2, 3) + + function f(a, b, c) { + sstore(a, b) + sstore(b, c) + } +} +// ---- +// step: functionSpecializer +// +// { +// f_1() +// function f_1() +// { +// let a_4 := 1 +// let b_3 := 2 +// let c_2 := 3 +// sstore(a_4, b_3) +// sstore(b_3, c_2) +// } +// function f(a, b, c) +// { +// sstore(a, b) +// sstore(b, c) +// } +// } diff --git a/test/libyul/yulOptimizerTests/functionSpecializer/smoke.yul b/test/libyul/yulOptimizerTests/functionSpecializer/smoke.yul new file mode 100644 index 000000000..3da8c4089 --- /dev/null +++ b/test/libyul/yulOptimizerTests/functionSpecializer/smoke.yul @@ -0,0 +1,5 @@ +{ } +// ---- +// step: functionSpecializer +// +// { } diff --git a/test/yulPhaser/Chromosome.cpp b/test/yulPhaser/Chromosome.cpp index ac4c49055..55bfd8f24 100644 --- a/test/yulPhaser/Chromosome.cpp +++ b/test/yulPhaser/Chromosome.cpp @@ -138,7 +138,7 @@ BOOST_AUTO_TEST_CASE(output_operator_should_create_concise_and_unambiguous_strin BOOST_TEST(chromosome.length() == allSteps.size()); BOOST_TEST(chromosome.optimisationSteps() == allSteps); - BOOST_TEST(toString(chromosome) == "flcCUnDvejsxIOoighTLMRrmVatpud"); + BOOST_TEST(toString(chromosome) == "flcCUnDvejsxIOoighFTLMRrmVatpud"); } BOOST_AUTO_TEST_CASE(optimisationSteps_should_translate_chromosomes_genes_to_optimisation_step_names)