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
Currently when simplifying instructions we only look at one instruction at a time for the most part.
For example, the program:
fnmain(x:Field){let x2 = x + 1 - 1;assert_eq(x, x2);}
Does not optimize out x2:
After Array Set Optimizations:
acir(inline) fn main f0 {
b0(v0: Field):
v9 = add v0, Field 1
v10 = sub v9, Field 1
constrain v0 == v10
return
}
Happy Case
There are many cases when multiple instructions could constant combine like this so I won't list them all. Another case as mentioned in #5691 is with addition and less than which can show up in length checks of arrays in some cases:
v23 = add v21, u32 1
v28 = lt v23, u32 9
Which could be simplified to:
v23 = lt v21, u32 8
There are a lot of checks we could add but I think this could be a relatively easy optimization win still since I anticipate patterns like this will show up in user code either directly or as the result of previous optimizations as in the lt case above.
Workaround
None
Workaround Description
No response
Additional Context
No response
Project Impact
None
Blocker Context
No response
Would you like to submit a PR for this Issue?
None
Support Needs
No response
The text was updated successfully, but these errors were encountered:
Problem
Currently when simplifying instructions we only look at one instruction at a time for the most part.
For example, the program:
Does not optimize out x2:
Happy Case
There are many cases when multiple instructions could constant combine like this so I won't list them all. Another case as mentioned in #5691 is with addition and less than which can show up in length checks of arrays in some cases:
Which could be simplified to:
There are a lot of checks we could add but I think this could be a relatively easy optimization win still since I anticipate patterns like this will show up in user code either directly or as the result of previous optimizations as in the
lt
case above.Workaround
None
Workaround Description
No response
Additional Context
No response
Project Impact
None
Blocker Context
No response
Would you like to submit a PR for this Issue?
None
Support Needs
No response
The text was updated successfully, but these errors were encountered: