mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Test multiple instructions with the (non)commutative peephole optimiser
This commit is contained in:
parent
17bcabb6cf
commit
be6051bead
@ -859,19 +859,29 @@ BOOST_AUTO_TEST_CASE(peephole_pop_calldatasize)
|
|||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(peephole_commutative_swap1)
|
BOOST_AUTO_TEST_CASE(peephole_commutative_swap1)
|
||||||
|
{
|
||||||
|
vector<Instruction> ops{
|
||||||
|
Instruction::ADD,
|
||||||
|
Instruction::MUL,
|
||||||
|
Instruction::EQ,
|
||||||
|
Instruction::AND,
|
||||||
|
Instruction::OR,
|
||||||
|
Instruction::XOR
|
||||||
|
};
|
||||||
|
for (Instruction const op: ops)
|
||||||
{
|
{
|
||||||
AssemblyItems items{
|
AssemblyItems items{
|
||||||
u256(1),
|
u256(1),
|
||||||
u256(2),
|
u256(2),
|
||||||
Instruction::SWAP1,
|
Instruction::SWAP1,
|
||||||
Instruction::ADD,
|
op,
|
||||||
u256(4),
|
u256(4),
|
||||||
u256(5)
|
u256(5)
|
||||||
};
|
};
|
||||||
AssemblyItems expectation{
|
AssemblyItems expectation{
|
||||||
u256(1),
|
u256(1),
|
||||||
u256(2),
|
u256(2),
|
||||||
Instruction::ADD,
|
op,
|
||||||
u256(4),
|
u256(4),
|
||||||
u256(5)
|
u256(5)
|
||||||
};
|
};
|
||||||
@ -882,14 +892,28 @@ BOOST_AUTO_TEST_CASE(peephole_commutative_swap1)
|
|||||||
expectation.begin(), expectation.end()
|
expectation.begin(), expectation.end()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(peephole_noncommutative_swap1)
|
BOOST_AUTO_TEST_CASE(peephole_noncommutative_swap1)
|
||||||
|
{
|
||||||
|
// NOTE: not comprehensive
|
||||||
|
vector<Instruction> ops{
|
||||||
|
Instruction::SUB,
|
||||||
|
Instruction::DIV,
|
||||||
|
Instruction::SDIV,
|
||||||
|
Instruction::MOD,
|
||||||
|
Instruction::SMOD,
|
||||||
|
Instruction::EXP,
|
||||||
|
Instruction::LT,
|
||||||
|
Instruction::GT
|
||||||
|
};
|
||||||
|
for (Instruction const op: ops)
|
||||||
{
|
{
|
||||||
AssemblyItems items{
|
AssemblyItems items{
|
||||||
u256(1),
|
u256(1),
|
||||||
u256(2),
|
u256(2),
|
||||||
Instruction::SWAP1,
|
Instruction::SWAP1,
|
||||||
Instruction::SUB,
|
op,
|
||||||
u256(4),
|
u256(4),
|
||||||
u256(5)
|
u256(5)
|
||||||
};
|
};
|
||||||
@ -897,7 +921,7 @@ BOOST_AUTO_TEST_CASE(peephole_noncommutative_swap1)
|
|||||||
u256(1),
|
u256(1),
|
||||||
u256(2),
|
u256(2),
|
||||||
Instruction::SWAP1,
|
Instruction::SWAP1,
|
||||||
Instruction::SUB,
|
op,
|
||||||
u256(4),
|
u256(4),
|
||||||
u256(5)
|
u256(5)
|
||||||
};
|
};
|
||||||
@ -908,6 +932,7 @@ BOOST_AUTO_TEST_CASE(peephole_noncommutative_swap1)
|
|||||||
expectation.begin(), expectation.end()
|
expectation.begin(), expectation.end()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(jumpdest_removal)
|
BOOST_AUTO_TEST_CASE(jumpdest_removal)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user