Convert certain and(mul(a, b), mask) and and(add(a, b), mask) into mulmod(a, b, x) and addmod(a, b, y) #10687
Comments
|
This sounds good in general, but I'm a bit concerned about this transform destroying some other potential opportunities. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For example the following solidity snippet
would be converted into (by the optimizer)
Here
_1is a shorter representation of the constant.Instead the more optimized version would be
It is shorter and avoids a
sub.and + mulhas the same gas asmulmod.Similarly, for
addmod, butadd + andis6, andaddmodis8. We save asub. So total saving of2gas and shorter deploy code.It maybe easier to implement this as a rule
and(mul(X, Y), A) -> mulmod(X, Y, 2**N)whereA = 2**N - 1. Similarly, for the other?The text was updated successfully, but these errors were encountered: