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

[ElimLoadStore] created -eliminate-affine-load-store #41

Merged
merged 1 commit into from
Oct 26, 2021

Conversation

kumasento
Copy link
Owner

@kumasento kumasento commented Oct 26, 2021

func @foo(%A: memref<?xf32>, %i: index, %a: f32) -> f32 {
  affine.store %a, %A[%i] : memref<?xf32>
  %v = affine.load %A[%i] : memref<?xf32>
  affine.store %a, %A[%i] : memref<?xf32>
  return %v : f32
}

will be squashed into

func @foo(%A: memref<?xf32>, %i: index, %a: f32) -> f32 {
  affine.store %a, %A[%i] : memref<?xf32>
  return %a : f32
}

func @foo(%A: memref<?xi32>) {
  %fst = affine.load %A[0] : memref<?xi32>
  %fst2 = affine.load %A[0] : memref<?xi32>
  // Should only leave one.

  affine.for %i = 1 to 10 {
    %cur1 = affine.load %A[%i] : memref<?xi32>
    %cur2 = affine.load %A[%i] : memref<?xi32>
    %next = affine.load %A[%i + 1] : memref<?xi32> // should not remove

    %doubled = arith.addi %cur1, %cur2 : i32
    %sum = arith.addi %next, %doubled : i32
    %final = arith.addi %fst2, %sum : i32

    affine.store %final, %A[100 + %i] : memref<?xi32>
  }

  return
}

will be simplified to

func @foo(%A: memref<?xi32>) {
  %fst = affine.load %A[0] : memref<?xi32>

  affine.for %i = 1 to 10 {
    %cur1 = affine.load %A[%i] : memref<?xi32>
    %next = affine.load %A[%i + 1] : memref<?xi32> // should not remove

    %doubled = arith.addi %cur1, %cur1 : i32
    %sum = arith.addi %next, %doubled : i32
    %final = arith.addi %fst, %sum : i32

    affine.store %final, %A[100 + %i] : memref<?xi32>
  }

  return
}

[ElimLoadStore] test for load seq w/ store/block

[ElimLoadStore] refactorization

[ElimLoadStore] handle load after store
@kumasento kumasento enabled auto-merge (rebase) October 26, 2021 16:09
@kumasento kumasento merged commit 49d0b1c into main Oct 26, 2021
@kumasento kumasento deleted the dev-elim-load-store branch October 26, 2021 16:31
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