solidity icon indicating copy to clipboard operation
solidity copied to clipboard

Optimize AND/SHL

Open chriseth opened this issue 5 years ago • 3 comments
trafficstars

and(shl(A, X), shl(A, Y)) should be optimized to shl(A, and(X, Y))

or even

and(shl(Z, X), shl(Z, Y)) should be optimized to shl(Z, and(X, Y))

chriseth avatar Jun 04 '20 08:06 chriseth

@chriseth I can't find any difference between the 2 provided examples? Is it a typo?

k06a avatar Feb 02 '22 15:02 k06a

The difference stems from how we internally formulate simplification rules in https://github.com/ethereum/solidity/blob/develop/libevmasm/RuleList.h and isn't clear in the issue description - we use A, B, C, ... for constants and X, Y, Z, ... for arbitrary expressions when pattern matching simplification rules.

ekpyron avatar Feb 02 '22 15:02 ekpyron

@ekpyron thx!

k06a avatar Feb 02 '22 17:02 k06a