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 RemoveUselessStores pass #2572

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

annagrin
Copy link
Collaborator

@annagrin annagrin commented Feb 1, 2025

Description

Add a pass for removing stores that are overriden 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 overriden 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!

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.

2 participants