mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Remove ReasoningBasedSimplifier from libyul
Due to a design decision to move away from a bundled SMT solver, ReasoningBasedSimplifier in its current form cannot be use any longer. This is a necessary step to allow a unified way to call solvers using only SMTLIB interface. Since this optimization pass has always been marked as highly experimental and never turned on by default, it should be OK to remove it.
This commit is contained in:
@@ -24,7 +24,6 @@
|
||||
#include <test/Common.h>
|
||||
|
||||
#include <libyul/Object.h>
|
||||
#include <libyul/optimiser/ReasoningBasedSimplifier.h>
|
||||
#include <libyul/AsmPrinter.h>
|
||||
|
||||
#include <liblangutil/CharStreamProvider.h>
|
||||
@@ -53,12 +52,6 @@ YulOptimizerTest::YulOptimizerTest(string const& _filename):
|
||||
BOOST_THROW_EXCEPTION(runtime_error("Filename path has to contain a directory: \"" + _filename + "\"."));
|
||||
m_optimizerStep = std::prev(std::prev(path.end()))->string();
|
||||
|
||||
if (m_optimizerStep == "reasoningBasedSimplifier" && (
|
||||
solidity::test::CommonOptions::get().disableSMT ||
|
||||
ReasoningBasedSimplifier::invalidInCurrentEnvironment()
|
||||
))
|
||||
m_shouldRun = false;
|
||||
|
||||
m_source = m_reader.source();
|
||||
|
||||
auto dialectName = m_reader.stringSetting("dialect", "evm");
|
||||
|
||||
@@ -49,7 +49,6 @@
|
||||
#include <libyul/optimiser/UnusedPruner.h>
|
||||
#include <libyul/optimiser/ExpressionJoiner.h>
|
||||
#include <libyul/optimiser/OptimiserStep.h>
|
||||
#include <libyul/optimiser/ReasoningBasedSimplifier.h>
|
||||
#include <libyul/optimiser/SSAReverser.h>
|
||||
#include <libyul/optimiser/SSATransform.h>
|
||||
#include <libyul/optimiser/Semantics.h>
|
||||
@@ -289,10 +288,6 @@ YulOptimizerTestCommon::YulOptimizerTestCommon(
|
||||
LiteralRematerialiser::run(*m_context, *m_ast);
|
||||
StructuralSimplifier::run(*m_context, *m_ast);
|
||||
}},
|
||||
{"reasoningBasedSimplifier", [&]() {
|
||||
disambiguate();
|
||||
ReasoningBasedSimplifier::run(*m_context, *m_object->code);
|
||||
}},
|
||||
{"equivalentFunctionCombiner", [&]() {
|
||||
disambiguate();
|
||||
ForLoopInitRewriter::run(*m_context, *m_ast);
|
||||
@@ -424,8 +419,7 @@ string YulOptimizerTestCommon::randomOptimiserStep(unsigned _seed)
|
||||
// it can sometimes drain memory.
|
||||
if (
|
||||
optimiserStep == "mainFunction" ||
|
||||
optimiserStep == "wordSizeTransform" ||
|
||||
optimiserStep == "reasoningBasedSimplifier"
|
||||
optimiserStep == "wordSizeTransform"
|
||||
)
|
||||
// "Fullsuite" is fuzzed roughly four times more frequently than
|
||||
// other steps because of the filtering in place above.
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
{
|
||||
let x := 7
|
||||
let y := 8
|
||||
if eq(add(x, y), 15) { }
|
||||
}
|
||||
// ----
|
||||
// step: reasoningBasedSimplifier
|
||||
//
|
||||
// {
|
||||
// let x := 7
|
||||
// let y := 8
|
||||
// if 1 { }
|
||||
// }
|
||||
@@ -1,19 +0,0 @@
|
||||
{
|
||||
function f() -> z
|
||||
{
|
||||
z := 15
|
||||
}
|
||||
let x := 7
|
||||
let y := 8
|
||||
if eq(add(x, y), f()) { }
|
||||
}
|
||||
// ----
|
||||
// step: reasoningBasedSimplifier
|
||||
//
|
||||
// {
|
||||
// function f() -> z
|
||||
// { z := 15 }
|
||||
// let x := 7
|
||||
// let y := 8
|
||||
// if eq(add(x, y), f()) { }
|
||||
// }
|
||||
@@ -1,23 +0,0 @@
|
||||
{
|
||||
function f() -> z
|
||||
{
|
||||
sstore(1, 15)
|
||||
z := 15
|
||||
}
|
||||
let x := 7
|
||||
let y := 8
|
||||
if eq(add(x, y), f()) { }
|
||||
}
|
||||
// ----
|
||||
// step: reasoningBasedSimplifier
|
||||
//
|
||||
// {
|
||||
// function f() -> z
|
||||
// {
|
||||
// sstore(1, 15)
|
||||
// z := 15
|
||||
// }
|
||||
// let x := 7
|
||||
// let y := 8
|
||||
// if eq(add(x, y), f()) { }
|
||||
// }
|
||||
@@ -1,32 +0,0 @@
|
||||
{
|
||||
let vloc_x := calldataload(0)
|
||||
let vloc_y := calldataload(1)
|
||||
if lt(vloc_x, shl(100, 1)) {
|
||||
if lt(vloc_y, shl(100, 1)) {
|
||||
if iszero(and(iszero(iszero(vloc_x)), gt(vloc_y, div(not(0), vloc_x)))) {
|
||||
let vloc := mul(vloc_x, vloc_y)
|
||||
sstore(0, vloc)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// EVMVersion: >=constantinople
|
||||
// ----
|
||||
// step: reasoningBasedSimplifier
|
||||
//
|
||||
// {
|
||||
// let vloc_x := calldataload(0)
|
||||
// let vloc_y := calldataload(1)
|
||||
// if lt(vloc_x, shl(100, 1))
|
||||
// {
|
||||
// if lt(vloc_y, shl(100, 1))
|
||||
// {
|
||||
// if 1
|
||||
// {
|
||||
// let vloc := mul(vloc_x, vloc_y)
|
||||
// sstore(0, vloc)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
@@ -1,31 +0,0 @@
|
||||
{
|
||||
let x := calldataload(0)
|
||||
let y := calldataload(32)
|
||||
let z := calldataload(64)
|
||||
let result := mulmod(x, y, z)
|
||||
|
||||
// should be zero
|
||||
if gt(result, z) { sstore(0, 1) }
|
||||
|
||||
// mulmod is equal to mod of product for small numbers
|
||||
if and(and(lt(x, 1000), lt(y, 1000)), lt(z, 1000)) {
|
||||
if eq(result, mod(mul(x, y), z)) { sstore(0, 9) }
|
||||
}
|
||||
|
||||
// but not in general
|
||||
if and(and(gt(x, sub(0, 5)), eq(y, 2)), eq(z, 3)) {
|
||||
if eq(result, mod(mul(x, y), z)) { sstore(0, 5) }
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// step: reasoningBasedSimplifier
|
||||
//
|
||||
// {
|
||||
// let x := calldataload(0)
|
||||
// let y := calldataload(32)
|
||||
// let z := calldataload(64)
|
||||
// let result := mulmod(x, y, z)
|
||||
// if 0 { }
|
||||
// if and(and(lt(x, 1000), lt(y, 1000)), lt(z, 1000)) { if 1 { sstore(0, 9) } }
|
||||
// if and(and(gt(x, sub(0, 5)), eq(y, 2)), eq(z, 3)) { if 0 { } }
|
||||
// }
|
||||
@@ -1,16 +0,0 @@
|
||||
{
|
||||
let x := sub(0, 7)
|
||||
let y := 2
|
||||
// (-7)/2 == -3 on the evm
|
||||
if iszero(add(sdiv(x, y), 3)) { }
|
||||
if iszero(add(sdiv(x, y), 4)) { }
|
||||
}
|
||||
// ----
|
||||
// step: reasoningBasedSimplifier
|
||||
//
|
||||
// {
|
||||
// let x := sub(0, 7)
|
||||
// let y := 2
|
||||
// if 1 { }
|
||||
// if 0 { }
|
||||
// }
|
||||
@@ -1,26 +0,0 @@
|
||||
{
|
||||
let x := calldataload(2)
|
||||
let t := lt(x, 20)
|
||||
if t {
|
||||
if lt(x, 21) { }
|
||||
if lt(x, 20) { }
|
||||
if lt(x, 19) { }
|
||||
if gt(x, 20) { }
|
||||
if iszero(gt(x, 20)) { }
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// step: reasoningBasedSimplifier
|
||||
//
|
||||
// {
|
||||
// let x := calldataload(2)
|
||||
// let t := lt(x, 20)
|
||||
// if t
|
||||
// {
|
||||
// if 1 { }
|
||||
// if 1 { }
|
||||
// if lt(x, 19) { }
|
||||
// if 0 { }
|
||||
// if 1 { }
|
||||
// }
|
||||
// }
|
||||
@@ -1,31 +0,0 @@
|
||||
{
|
||||
let y := calldataload(0)
|
||||
let t := calldataload(32)
|
||||
|
||||
if sgt(sub(y, 1), y) {
|
||||
// y - 1 > y, i.e. y is the most negative value
|
||||
if eq(sdiv(y, sub(0, 1)), y) {
|
||||
// should be true: y / -1 == y
|
||||
sstore(0, 7)
|
||||
}
|
||||
if iszero(eq(y, t)) {
|
||||
// t is not the most negative value
|
||||
if eq(sdiv(t, sub(0, 1)), sub(0, t)) {
|
||||
// should be true: t / -1 = 0 - t
|
||||
sstore(1, 7)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// step: reasoningBasedSimplifier
|
||||
//
|
||||
// {
|
||||
// let y := calldataload(0)
|
||||
// let t := calldataload(32)
|
||||
// if sgt(sub(y, 1), y)
|
||||
// {
|
||||
// if 1 { sstore(0, 7) }
|
||||
// if iszero(eq(y, t)) { if 1 { sstore(1, 7) } }
|
||||
// }
|
||||
// }
|
||||
@@ -1,53 +0,0 @@
|
||||
{
|
||||
// 7 % 5 == 2
|
||||
// 7 % -5 == 2
|
||||
// -7 % 5 == -2
|
||||
// -7 % -5 == -2
|
||||
// -5 % -5 == 0
|
||||
let x := calldataload(0)
|
||||
let y := calldataload(32)
|
||||
let result := smod(x, y)
|
||||
if eq(x, 7) {
|
||||
if eq(y, 5) {
|
||||
if eq(result, 2) { sstore(0, 7)}
|
||||
}
|
||||
if eq(y, sub(0, 5)) {
|
||||
if eq(result, 2) { sstore(0, 7)}
|
||||
}
|
||||
}
|
||||
if eq(x, sub(0, 7)) {
|
||||
if eq(y, 5) {
|
||||
if eq(result, sub(0, 2)) { sstore(0, 7)}
|
||||
}
|
||||
if eq(y, sub(0, 5)) {
|
||||
if eq(result, sub(0, 2)) { sstore(0, 7)}
|
||||
}
|
||||
}
|
||||
if eq(x, sub(0, 5)) {
|
||||
if eq(y, sub(0, 5)) {
|
||||
if eq(result, 0) { sstore(0, 7)}
|
||||
}
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// step: reasoningBasedSimplifier
|
||||
//
|
||||
// {
|
||||
// let x := calldataload(0)
|
||||
// let y := calldataload(32)
|
||||
// let result := smod(x, y)
|
||||
// if eq(x, 7)
|
||||
// {
|
||||
// if eq(y, 5) { if 1 { sstore(0, 7) } }
|
||||
// if eq(y, sub(0, 5)) { if 1 { sstore(0, 7) } }
|
||||
// }
|
||||
// if eq(x, sub(0, 7))
|
||||
// {
|
||||
// if eq(y, 5) { if 1 { sstore(0, 7) } }
|
||||
// if eq(y, sub(0, 5)) { if 1 { sstore(0, 7) } }
|
||||
// }
|
||||
// if eq(x, sub(0, 5))
|
||||
// {
|
||||
// if eq(y, sub(0, 5)) { if 1 { sstore(0, 7) } }
|
||||
// }
|
||||
// }
|
||||
@@ -1,5 +0,0 @@
|
||||
{ }
|
||||
// ----
|
||||
// step: reasoningBasedSimplifier
|
||||
//
|
||||
// { }
|
||||
@@ -1,15 +0,0 @@
|
||||
{
|
||||
let x := 7
|
||||
let y := 8
|
||||
if gt(sub(x, y), 20) { }
|
||||
if eq(sub(x, y), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) {}
|
||||
}
|
||||
// ----
|
||||
// step: reasoningBasedSimplifier
|
||||
//
|
||||
// {
|
||||
// let x := 7
|
||||
// let y := 8
|
||||
// if 1 { }
|
||||
// if 1 { }
|
||||
// }
|
||||
@@ -37,7 +37,6 @@
|
||||
#include <libyul/optimiser/StackCompressor.h>
|
||||
#include <libyul/optimiser/VarNameCleaner.h>
|
||||
#include <libyul/optimiser/Suite.h>
|
||||
#include <libyul/optimiser/ReasoningBasedSimplifier.h>
|
||||
|
||||
#include <libyul/backends/evm/EVMDialect.h>
|
||||
|
||||
|
||||
@@ -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) == "flcCUnDEvejsxIOoighFTLMRmVatrpuSd");
|
||||
BOOST_TEST(toString(chromosome) == "flcCUnDEvejsxIOoighFTLMmVatrpuSd");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(optimisationSteps_should_translate_chromosomes_genes_to_optimisation_step_names)
|
||||
|
||||
Reference in New Issue
Block a user