You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If a variable is not going to be used after a given expression, no need to save it to memory.
If a variable is updated several times in a row, no need to save intermediate results to memory.
Test Cases
Input Yul
{
let a := 700
let b := 100
let c := 200
let d := add(a, c)
}
Assembly Output
// a gets pushed to the stack
// b gets pushed to the stack
// The stack is full, so the top value will attempt to save to memory
//Since b is the top value, the optimizer will check if b is used later
//if so, b gets saved to memory, if not, b gets dropped
//then c gets pushed to the stack
//a and c are added
Input Yul
let c = 1000
let b = 15
let a = 6
let d = mul(a, b)
let e = mul(d, a)
Assembly Output
// Assembly output should not put d back on the stack,
// because it is immediately used after, since in
// multiplication the intermediate value
// must be stored in memory.
Activity
ControlCplusControlV commentedon Dec 17, 2022
Lifetime Management
Test Cases