solidity/test/libyul/yulOptimizerTests/rematerialiser/medium_sized_constant.yul
2019-04-03 14:58:20 +02:00

27 lines
534 B
Plaintext

{
// Constants cost depending on their magnitude.
// Rematerialize small constants only if they are
// not used too often.
// b is used 5 times
let b := 2
mstore(b, b)
mstore(add(b, b), b)
// a is used 7 times
let a := 1
mstore(a, a)
mstore(add(a, a), a)
mstore(a, mload(a))
}
// ====
// step: rematerialiser
// ----
// {
// let b := 2
// mstore(2, 2)
// mstore(add(2, 2), 2)
// let a := 1
// mstore(a, a)
// mstore(add(a, a), a)
// mstore(a, mload(a))
// }