-
Notifications
You must be signed in to change notification settings - Fork 6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unexpected SLOADs during storing tightly packed struct #12460
Comments
Solidity is still not very good at optimizing across memory stores ( It is weird, though, that slot |
@chriseth I tried this code too, even before using structs. I have the same SLOADs and SSTOREs counts but no MLOADs and MSTOREs :) |
Looked at the IR. The issue is that the function calls for writing to storage, corresponding to |
@hrkrshnn what do you think about adding tests for such cases? |
I don't think we have an issue with inlining in the old codegen, because most routines are always inlined at code gen phase already. I would still like the sload of zero to be investigated. |
@k06a we already have tests for that and we know that the gas consumption is far from ideal. I just re-checked the version where we store in struct members directly, i.e.
And the code generated via ir does perform multiple stores, but it does not read from the storage slot for the final store (the multiple stores will be fixed by #11352 ). |
For reference, IR code:
|
@chriseth what do you think about fixing and adding tests for such cases to avoid future regressions? |
@ekpyron thanks, amazing! |
This issue has been marked as stale due to inactivity for the last 90 days. |
Hi everyone! This issue has been automatically closed due to inactivity. |
Description
Unexpected SLOADs during storing tightly packed struct. The following code should produce 0 SLOADs and 2 SSTOREs from my point of view. But somehow it executes 1 SLOAD before SSTOREs.
Environment
Steps to Reproduce
The text was updated successfully, but these errors were encountered: