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

Add WriteAfterWriteElimination pass #2572

Merged
merged 8 commits into from
Feb 4, 2025
Merged

Conversation

annagrin
Copy link
Collaborator

@annagrin annagrin commented Feb 1, 2025

Description

Add a pass for removing stores that are overridden by other stores

Example:

func.func @test_two_stores_same_pointer() {
  %c0_i64 = arith.constant 0 : i64
  %0 = quake.alloca !quake.veq<2>
  %1 = cc.const_array [1] : !cc.array<i64 x 1>
  %2 = cc.extract_value %1[0] : (!cc.array<i64 x 1>) -> i64
  %3 = cc.alloca !cc.array<i64 x 1>
  %4 = cc.cast %3 : (!cc.ptr<!cc.array<i64 x 1>>) -> !cc.ptr<i64>
  cc.store %c0_i64, %4 : !cc.ptr<i64>
  cc.store %2, %4 : !cc.ptr<i64>
  %5 = cc.load %4 : !cc.ptr<i64>
  %6 = quake.extract_ref %0[%5] : (!quake.veq<2>, i64) -> !quake.ref
  quake.x %6 : (!quake.ref) -> ()
  return
}

The in the last two stores, the first one can be removed because it is overridden by the next.

  cc.store %c0_i64, %4 : !cc.ptr<i64>
  cc.store %2, %4 : !cc.ptr<i64>

Signed-off-by: Anna Gringauze <[email protected]>
Copy link

github-actions bot commented Feb 1, 2025

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

github-actions bot pushed a commit that referenced this pull request Feb 1, 2025
Copy link

@iqbalbhatti49 iqbalbhatti49 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary:

The code looks great overall! You've followed best practices, and the implementation is clean and efficient. The logic is sound, and I appreciate the attention to detail in the structure.

Highlights:

  • Code is well-organized and easy to follow.
  • Proper handling of edge cases.
  • Clear variable naming makes the code readable.

Overall, I approve this change and recommend merging it. Great work!

@annagrin annagrin requested a review from schweitzpgi February 2, 2025 01:23
Copy link

github-actions bot commented Feb 2, 2025

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

github-actions bot pushed a commit that referenced this pull request Feb 2, 2025
Copy link
Collaborator

@schweitzpgi schweitzpgi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Useless" sounds a little judgmental or something to me. Maybe WAW elimination or WAW removal sounds less aggressive? heh

Signed-off-by: Anna Gringauze <[email protected]>
@annagrin annagrin changed the title Add RemoveUselessStores pass Add WriteAfterWriteElimination pass Feb 3, 2025
Copy link

github-actions bot commented Feb 3, 2025

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

github-actions bot pushed a commit that referenced this pull request Feb 3, 2025
@annagrin annagrin enabled auto-merge (squash) February 4, 2025 00:29
Signed-off-by: Anna Gringauze <[email protected]>
Copy link

github-actions bot commented Feb 4, 2025

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

github-actions bot pushed a commit that referenced this pull request Feb 4, 2025
Copy link

github-actions bot commented Feb 4, 2025

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

github-actions bot pushed a commit that referenced this pull request Feb 4, 2025
@annagrin annagrin merged commit 0a8c67e into NVIDIA:main Feb 4, 2025
211 checks passed
github-actions bot pushed a commit that referenced this pull request Feb 4, 2025
Copy link

github-actions bot commented Feb 4, 2025

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

github-actions bot pushed a commit that referenced this pull request Feb 4, 2025
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.

3 participants