Closed kumasento closed 3 years ago
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 }
will be squashed into
will be simplified to