summaryrefslogtreecommitdiffstats
path: root/mlir/test/Transforms
diff options
context:
space:
mode:
authorAlex Zinenko <zinenko@google.com>2019-12-04 07:41:55 -0800
committerA. Unique TensorFlower <gardener@tensorflow.org>2019-12-04 07:42:29 -0800
commit75175134d46dd63fda804697cbd3e66e8213a01b (patch)
tree9ec6d147c3993e1f690f6bb5fa9f4414d38c0750 /mlir/test/Transforms
parentf7c6bc70a926bf2fb790c4cfc2b6023dd21be622 (diff)
downloadbcm5719-llvm-75175134d46dd63fda804697cbd3e66e8213a01b.tar.gz
bcm5719-llvm-75175134d46dd63fda804697cbd3e66e8213a01b.zip
Loop coalescing: fix pointer chainsing in use-chain traversal
In the replaceAllUsesExcept utility function called from loop coalescing the iteration over the use-chain is incorrect. The use list nodes (IROperands) have next/prev links, and bluntly resetting the use would make the loop to continue on uses of the value that was replaced instead of the original one. As a result, it could miss the existing uses and update the wrong ones. Make sure we increment the iterator before updating the use in the loop body. Reported-by: Uday Bondhugula <uday@polymagelabs.com> Closes tensorflow/mlir#291. PiperOrigin-RevId: 283754195
Diffstat (limited to 'mlir/test/Transforms')
-rw-r--r--mlir/test/Transforms/loop-coalescing.mlir32
1 files changed, 32 insertions, 0 deletions
diff --git a/mlir/test/Transforms/loop-coalescing.mlir b/mlir/test/Transforms/loop-coalescing.mlir
index cf0d4f5ce2e..45e2b5d07fc 100644
--- a/mlir/test/Transforms/loop-coalescing.mlir
+++ b/mlir/test/Transforms/loop-coalescing.mlir
@@ -40,6 +40,38 @@ func @one_3d_nest() {
return
}
+// Check that there is no chasing the replacement of value uses by ensuring
+// multiple uses of loop induction variables get rewritten to the same values.
+
+// CHECK-LABEL: @multi_use
+func @multi_use() {
+ %c0 = constant 0 : index
+ %c1 = constant 1 : index
+ %c10 = constant 10 : index
+ // CHECK: loop.for %[[iv:.*]] =
+ loop.for %i = %c1 to %c10 step %c1 {
+ loop.for %j = %c1 to %c10 step %c1 {
+ loop.for %k = %c1 to %c10 step %c1 {
+ // CHECK: %[[k_unshifted:.*]] = remis %[[iv]], %[[k_extent:.*]]
+ // CHECK: %[[ij:.*]] = divis %[[iv]], %[[k_extent]]
+ // CHECK: %[[j_unshifted:.*]] = remis %[[ij]], %[[j_extent:.*]]
+ // CHECK: %[[i_unshifted:.*]] = divis %[[ij]], %[[j_extent]]
+ // CHECK: %[[k:.*]] = addi %[[k_unshifted]]
+ // CHECK: %[[j:.*]] = addi %[[j_unshifted]]
+ // CHECK: %[[i:.*]] = addi %[[i_unshifted]]
+
+ // CHECK: "use1"(%[[i]], %[[j]], %[[k]])
+ "use1"(%i,%j,%k) : (index,index,index) -> ()
+ // CHECK: "use2"(%[[i]], %[[k]], %[[j]])
+ "use2"(%i,%k,%j) : (index,index,index) -> ()
+ // CHECK: "use3"(%[[k]], %[[j]], %[[i]])
+ "use3"(%k,%j,%i) : (index,index,index) -> ()
+ }
+ }
+ }
+ return
+}
+
func @unnormalized_loops() {
// CHECK: %[[orig_step_i:.*]] = constant 2
// CHECK: %[[orig_step_j:.*]] = constant 3
OpenPOWER on IntegriCloud