mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
26 lines
520 B
Plaintext
26 lines
520 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))
|
|
}
|
|
// ----
|
|
// 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))
|
|
// }
|