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
In the expression (a + b) - (a + b)/4, "common subexpression" refers to the duplicated (a + b). Compilers implementing this technique realize that (a + b) will not change, and so only calculate its value once.
letc :=add(100, 15)
leta :=add(45, 50)
letb :=add(a, c)
letd :=add(a, c)
Test Cases
Input Yul
{
let c := add(100, 15)
let a := add(45, 50)
let b := add(a, c)
let d := add(a, c)
}
Assembly Output
use.std::math::u256
begin
# Assigning to c #
# add() #
# u32 literal 100 #
push.100
# u32 literal 15 #
push.15
add
# Assigning to a #
# add() #
# u32 literal 45 #
push.45
# u32 literal 50 #
push.50
add
# Assigning to b #
# add() #
# pushing a to the top #
dup.0
# pushing c to the top #
dup.2
add
# Assigning to d #
dup
end
Should be compiled down to only evaluate a + c once, then Copy the value rather than re-computing it
No description provided.
The text was updated successfully, but these errors were encountered: