Skip to content

Fix compound assignment#2087

Open
tgrant-nv wants to merge 3 commits intoAcademySoftwareFoundation:mainfrom
tgrant-nv:fix-compound-assignment
Open

Fix compound assignment#2087
tgrant-nv wants to merge 3 commits intoAcademySoftwareFoundation:mainfrom
tgrant-nv:fix-compound-assignment

Conversation

@tgrant-nv
Copy link
Contributor

Description

This change removes the de-sugaring of a += b; into a = a + b; that was happening very early during the AST construction, and instead makes the generation of OSO IR make sure the a side is evaluated only once.

This is because the old behavior wouldn't handle correctly uses like a[i++] += b[j++]; (which is the array form of a += b; in a way). Because the old behavior would evaluate the a side twice, it would increment i twice, summing the elements of b to the even elements of a, and possibly accessing outside of the bounds of a.

Tests

Checklist:

  • I have read the contribution guidelines.
  • I have updated the documentation, if applicable.
  • I have ensured that the change is tested somewhere in the testsuite (adding new test cases if necessary).
  • My code follows the prevailing code style of this project. If I haven't
    already run clang-format v17 before submitting, I definitely will look at
    the CI test that runs clang-format and fix anything that it highlights as
    being nonconforming.

@tgrant-nv
Copy link
Contributor Author

Luca and I will look into these CI failures and update the PR ASAP. This is not a failure we saw in our testing, but I also did not enable batching.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant