Skip to content
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

Array indices reuse preventing array simplification #6419

Open
emesare opened this issue Feb 15, 2025 · 0 comments
Open

Array indices reuse preventing array simplification #6419

emesare opened this issue Feb 15, 2025 · 0 comments
Labels
Core: HLIL Issue involves High Level IL Effort: Medium Issue should take < 1 month Impact: Medium Issue is impactful with a bad, or no, workaround

Comments

@emesare
Copy link
Member

emesare commented Feb 15, 2025

Bug Description:
It appears if the array index is reused in another block (or perhaps even the same block) that the array access is not shown (i.e. array[idx]). This is because the current array simplification occurs on a simple expression, and to get that expression (i.e. &array + idx) we must have folded in the index, a reuse of the array index would likely prevent that fold from occurring.

Expected Behavior:
There are a few solutions:

  1. Loosen the folding rules when the use sites are all in a probable array access expression (i.e. check for array type), this is probably expensive.
  2. In array access simplification we can follow to defsite and fold the array index in while we are doing our transformation, not exactly sure about the implications of doing this, its probably fine so long as we keep the defsite and let it get DCE'd later.

Screenshots/Video Recording:

Working:
Image

Broken:
Image

As you can see there is no reuse of the array index (the highlighted token) in the working sample, but there is in the broken sample.

Binary
array_simpl.zip

@emesare emesare added Core: HLIL Issue involves High Level IL Impact: Medium Issue is impactful with a bad, or no, workaround labels Feb 15, 2025
@xusheng6 xusheng6 added the Effort: Medium Issue should take < 1 month label Feb 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Core: HLIL Issue involves High Level IL Effort: Medium Issue should take < 1 month Impact: Medium Issue is impactful with a bad, or no, workaround
Projects
None yet
Development

No branches or pull requests

2 participants