[Mlir-commits] [mlir] 5e080df - [MLIR] NFC: modernize affine loop fusion test cases
Mehdi Amini
llvmlistbot at llvm.org
Sun Mar 8 21:28:09 PDT 2020
Author: Uday Bondhugula
Date: 2020-03-09T04:27:51Z
New Revision: 5e080dff756400f0fc92a6123230113777738c4c
URL: https://github.com/llvm/llvm-project/commit/5e080dff756400f0fc92a6123230113777738c4c
DIFF: https://github.com/llvm/llvm-project/commit/5e080dff756400f0fc92a6123230113777738c4c.diff
LOG: [MLIR] NFC: modernize affine loop fusion test cases
- update test case for readability, avoid unnecessary matches
Signed-off-by: Uday Bondhugula <uday at polymagelabs.com>
Differential Revision: https://reviews.llvm.org/D75823
Added:
Modified:
mlir/test/Transforms/loop-fusion.mlir
Removed:
################################################################################
diff --git a/mlir/test/Transforms/loop-fusion.mlir b/mlir/test/Transforms/loop-fusion.mlir
index 136968263859..89140e42bd8f 100644
--- a/mlir/test/Transforms/loop-fusion.mlir
+++ b/mlir/test/Transforms/loop-fusion.mlir
@@ -23,7 +23,7 @@ func @should_fuse_raw_dep_for_locality() {
}
// CHECK: affine.for %{{.*}} = 0 to 10 {
// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[0] : memref<1xf32>
- // CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[0] : memref<1xf32>
+ // CHECK-NEXT: affine.load %{{.*}}[0] : memref<1xf32>
// CHECK-NEXT: }
// CHECK-NEXT: return
return
@@ -56,12 +56,12 @@ func @should_fuse_reduction_to_pointwise() {
// is not used in the access function of the store/load on %b.
// CHECK: affine.for %{{.*}} = 0 to 10 {
// CHECK-NEXT: affine.for %{{.*}} = 0 to 10 {
- // CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[0] : memref<1xf32>
- // CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[%{{.*}}, %{{.*}}] : memref<10x10xf32>
- // CHECK-NEXT: %{{.*}} = addf %{{.*}}, %{{.*}} : f32
+ // CHECK-NEXT: affine.load %{{.*}}[0] : memref<1xf32>
+ // CHECK-NEXT: affine.load %{{.*}}[%{{.*}}, %{{.*}}] : memref<10x10xf32>
+ // CHECK-NEXT: addf %{{.*}}, %{{.*}} : f32
// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[0] : memref<1xf32>
// CHECK-NEXT: }
- // CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[0] : memref<1xf32>
+ // CHECK-NEXT: affine.load %{{.*}}[0] : memref<1xf32>
// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[%{{.*}}] : memref<10xf32>
// CHECK-NEXT: }
// CHECK-NEXT: return
@@ -71,7 +71,8 @@ func @should_fuse_reduction_to_pointwise() {
// -----
// CHECK-DAG: [[MAP_SHIFT_MINUS_ONE_R1:#map[0-9]+]] = affine_map<(d0) -> (d0 - 1)>
-// CHECK-DAG: [[MAP_SHIFT_BY_ONE:#map[0-9]+]] = affine_map<(d0) -> (d0 + 1)>
+// CHECK-DAG: [[MAP_SHIFT_D0_BY_ONE:#map[0-9]+]] = affine_map<(d0, d1) -> (d0 + 1)>
+// CHECK-DAG: [[MAP_SHIFT_D1_BY_ONE:#map[0-9]+]] = affine_map<(d0, d1) -> (d1 + 1)>
// CHECK-LABEL: func @should_fuse_loop_nests_with_shifts() {
func @should_fuse_loop_nests_with_shifts() {
@@ -80,9 +81,7 @@ func @should_fuse_loop_nests_with_shifts() {
affine.for %i0 = 0 to 9 {
affine.for %i1 = 0 to 9 {
- %idx = affine.apply affine_map<(d0) -> (d0 + 1)> (%i0)
- %idy = affine.apply affine_map<(d0) -> (d0 + 1)> (%i1)
- affine.store %cf7, %a[%idx, %idy] : memref<10x10xf32>
+ affine.store %cf7, %a[%i0 + 1, %i1 + 1] : memref<10x10xf32>
}
}
affine.for %i2 = 1 to 10 {
@@ -101,12 +100,12 @@ func @should_fuse_loop_nests_with_shifts() {
// NOTE: Should create a private memref with reduced shape 9x9xf32.
// CHECK: affine.for %{{.*}} = 1 to 10 {
// CHECK-NEXT: affine.for %{{.*}} = 1 to 10 {
- // CHECK-NEXT: %{{.*}} = affine.apply [[MAP_SHIFT_MINUS_ONE_R1]](%{{.*}})
- // CHECK-NEXT: %{{.*}} = affine.apply [[MAP_SHIFT_MINUS_ONE_R1]](%{{.*}})
- // CHECK-NEXT: %{{.*}} = affine.apply [[MAP_SHIFT_BY_ONE]](%{{.*}})
- // CHECK-NEXT: %{{.*}} = affine.apply [[MAP_SHIFT_BY_ONE]](%{{.*}})
+ // CHECK-NEXT: %[[I:.*]] = affine.apply [[MAP_SHIFT_MINUS_ONE_R1]](%{{.*}})
+ // CHECK-NEXT: %[[J:.*]] = affine.apply [[MAP_SHIFT_MINUS_ONE_R1]](%{{.*}})
+ // CHECK-NEXT: affine.apply [[MAP_SHIFT_D0_BY_ONE]](%[[I]], %[[J]])
+ // CHECK-NEXT: affine.apply [[MAP_SHIFT_D1_BY_ONE]](%[[I]], %[[J]])
// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[0, 0] : memref<1x1xf32>
- // CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[0, 0] : memref<1x1xf32>
+ // CHECK-NEXT: affine.load %{{.*}}[0, 0] : memref<1x1xf32>
// CHECK-NEXT: }
// CHECK-NEXT: }
// CHECK-NEXT: return
@@ -143,9 +142,9 @@ func @should_fuse_loop_nest() {
// CHECK: affine.for %{{.*}} = 0 to 10 {
// CHECK-NEXT: affine.for %{{.*}} = 0 to 10 {
// CHECK-NEXT: affine.store %{{.*}}, [[NEWA]][0, 0] : memref<1x1xf32>
- // CHECK-NEXT: %{{.*}} = affine.load [[NEWA]][0, 0] : memref<1x1xf32>
+ // CHECK-NEXT: affine.load [[NEWA]][0, 0] : memref<1x1xf32>
// CHECK-NEXT: affine.store %{{.*}}, [[NEWB]][0, 0] : memref<1x1xf32>
- // CHECK-NEXT: %{{.*}} = affine.load [[NEWB]][0, 0] : memref<1x1xf32>
+ // CHECK-NEXT: affine.load [[NEWB]][0, 0] : memref<1x1xf32>
// CHECK-NEXT: }
// CHECK-NEXT: }
// CHECK-NEXT: return
@@ -179,9 +178,9 @@ func @should_fuse_across_intermediate_loop_with_no_deps() {
// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[%{{.*}}] : memref<10xf32>
// CHECK-NEXT: }
// CHECK: affine.for %{{.*}} = 0 to 10 {
- // CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[%{{.*}}] : memref<10xf32>
+ // CHECK-NEXT: affine.load %{{.*}}[%{{.*}}] : memref<10xf32>
// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[0] : memref<1xf32>
- // CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[0] : memref<1xf32>
+ // CHECK-NEXT: affine.load %{{.*}}[0] : memref<1xf32>
// CHECK-NEXT: }
// CHECK-NEXT: return
return
@@ -214,8 +213,8 @@ func @should_fuse_all_loops() {
// CHECK: affine.for %{{.*}} = 0 to 10 {
// CHECK-NEXT: affine.store %{{.*}}, [[NEWA]][0] : memref<1xf32>
// CHECK-NEXT: affine.store %{{.*}}, [[NEWB]][0] : memref<1xf32>
- // CHECK-NEXT: %{{.*}} = affine.load [[NEWA]][0] : memref<1xf32>
- // CHECK-NEXT: %{{.*}} = affine.load [[NEWB]][0] : memref<1xf32>
+ // CHECK-NEXT: affine.load [[NEWA]][0] : memref<1xf32>
+ // CHECK-NEXT: affine.load [[NEWB]][0] : memref<1xf32>
// CHECK-NEXT: }
// CHECK-NEXT: return
return
@@ -246,11 +245,11 @@ func @should_fuse_first_and_second_loops() {
// Should create private memref '%2' for fused loop.
// CHECK: affine.for %{{.*}} = 0 to 10 {
// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[0] : memref<1xf32>
- // CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[0] : memref<1xf32>
+ // CHECK-NEXT: affine.load %{{.*}}[0] : memref<1xf32>
// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[%{{.*}}] : memref<10xf32>
// CHECK-NEXT: }
// CHECK: affine.for %{{.*}} = 0 to 10 {
- // CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[%{{.*}}] : memref<10xf32>
+ // CHECK-NEXT: affine.load %{{.*}}[%{{.*}}] : memref<10xf32>
// CHECK-NEXT: }
// CHECK-NEXT: return
@@ -285,15 +284,15 @@ func @should_not_fuse_would_create_cycle() {
}
// Should not fuse: fusing loop first loop into last would create a cycle.
// CHECK: affine.for %{{.*}} = 0 to 10 {
- // CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[%{{.*}}] : memref<10xf32>
+ // CHECK-NEXT: affine.load %{{.*}}[%{{.*}}] : memref<10xf32>
// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[%{{.*}}] : memref<10xf32>
// CHECK-NEXT: }
// CHECK: affine.for %{{.*}} = 0 to 10 {
// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[%{{.*}}] : memref<10xf32>
- // CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[%{{.*}}] : memref<10xf32>
+ // CHECK-NEXT: affine.load %{{.*}}[%{{.*}}] : memref<10xf32>
// CHECK-NEXT: }
// CHECK: affine.for %{{.*}} = 0 to 10 {
- // CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[%{{.*}}] : memref<10xf32>
+ // CHECK-NEXT: affine.load %{{.*}}[%{{.*}}] : memref<10xf32>
// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[%{{.*}}] : memref<10xf32>
// CHECK-NEXT: }
// CHECK-NEXT: return
@@ -320,11 +319,11 @@ func @should_fuse_producer_consumer() {
// %i1, but OK to fuse %i1 into %i2.
// TODO(andydavis) When the fusion pass is run to a fixed-point, it should
// fuse all three of these loop nests.
- // CHECK: %{{.*}} = alloc() : memref<1xf32>
+ // CHECK: alloc() : memref<1xf32>
// CHECK: affine.for %{{.*}} = 0 to 10 {
// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[0] : memref<1xf32>
// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[0] : memref<1xf32>
- // CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[0] : memref<1xf32>
+ // CHECK-NEXT: affine.load %{{.*}}[0] : memref<1xf32>
// CHECK-NEXT: }
// CHECK-NEXT: return
return
@@ -352,9 +351,9 @@ func @should_fuse_and_move_to_preserve_war_dep() {
// into '%i2' if we move the fused loop nest before '%i1', which preserves
// the WAR dependence from load '%a' in '%i0' to the store '%a' in loop '%i1'.
// CHECK: affine.for %{{.*}} = 0 to 10 {
- // CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[%{{.*}}] : memref<10xf32>
+ // CHECK-NEXT: affine.load %{{.*}}[%{{.*}}] : memref<10xf32>
// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[0] : memref<1xf32>
- // CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[0] : memref<1xf32>
+ // CHECK-NEXT: affine.load %{{.*}}[0] : memref<1xf32>
// CHECK-NEXT: }
// CHECK-NEXT: affine.for %{{.*}} = 0 to 10 {
// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[%{{.*}}] : memref<10xf32>
@@ -385,7 +384,7 @@ func @should_fuse_with_private_memref_if_top_level_access() {
// CHECK-NEXT: }
// CHECK-NEXT: affine.for %{{.*}} = 0 to 10 {
// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[0] : memref<1xf32>
- // CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[0] : memref<1xf32>
+ // CHECK-NEXT: affine.load %{{.*}}[0] : memref<1xf32>
// CHECK-NEXT: }
return
}
@@ -405,7 +404,7 @@ func @should_fuse_no_top_level_access() {
}
// CHECK: affine.for %{{.*}} = 0 to 10 {
// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[0] : memref<1xf32>
- // CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[0] : memref<1xf32>
+ // CHECK-NEXT: affine.load %{{.*}}[0] : memref<1xf32>
// CHECK-NEXT: }
// CHECK-NEXT: return
return
@@ -434,7 +433,7 @@ func @should_not_fuse_if_inst_at_top_level() {
// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[%{{.*}}] : memref<10xf32>
// CHECK-NEXT: }
// CHECK: affine.for %{{.*}} = 0 to 10 {
- // CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[%{{.*}}] : memref<10xf32>
+ // CHECK-NEXT: affine.load %{{.*}}[%{{.*}}] : memref<10xf32>
// CHECK-NEXT: }
return
}
@@ -464,8 +463,8 @@ func @should_not_fuse_if_inst_in_loop_nest() {
// CHECK-NEXT: }
// CHECK: affine.for %{{.*}} = 0 to 10 {
// CHECK-NEXT: affine.if #set0(%{{.*}}) {
- // CHECK-NEXT: }
- // CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[%{{.*}}] : memref<10xf32>
+ // CHECK-NEXT: }
+ // CHECK-NEXT: affine.load %{{.*}}[%{{.*}}] : memref<10xf32>
// CHECK-NEXT: }
return
}
@@ -496,7 +495,7 @@ func @permute_and_fuse() {
// CHECK-NEXT: affine.for %{{.*}} = 0 to 10 {
// CHECK-NEXT: affine.for %{{.*}} = 0 to 20 {
// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[0, 0, 0] : memref<1x1x1xf32>
-// CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[0, 0, 0] : memref<1x1x1xf32>
+// CHECK-NEXT: affine.load %{{.*}}[0, 0, 0] : memref<1x1x1xf32>
// CHECK-NEXT: "foo"(%{{.*}}) : (f32) -> ()
// CHECK-NEXT: }
// CHECK-NEXT: }
@@ -519,9 +518,7 @@ func @fuse_reshape_64_16_4(%in : memref<64xf32>) {
affine.for %i0 = 0 to 64 {
%v = affine.load %in[%i0] : memref<64xf32>
- %idx = affine.apply affine_map<(d0) -> (d0 floordiv 4)> (%i0)
- %idy = affine.apply affine_map<(d0) -> (d0 mod 4)> (%i0)
- affine.store %v, %out[%idx, %idy] : memref<16x4xf32>
+ affine.store %v, %out[%i0 floordiv 4, %i0 mod 4] : memref<16x4xf32>
}
affine.for %i1 = 0 to 16 {
@@ -553,8 +550,7 @@ func @fuse_reshape_16_4_64() {
affine.for %i0 = 0 to 16 {
affine.for %i1 = 0 to 4 {
%v = affine.load %in[%i0, %i1] : memref<16x4xf32>
- %idx = affine.apply affine_map<(d0, d1) -> (4*d0 + d1)> (%i0, %i1)
- affine.store %v, %out[%idx] : memref<64xf32>
+ affine.store %v, %out[4*%i0 + %i1] : memref<64xf32>
}
}
@@ -563,12 +559,12 @@ func @fuse_reshape_16_4_64() {
"foo"(%w) : (f32) -> ()
}
// CHECK: affine.for %{{.*}} = 0 to 64 {
-// CHECK-NEXT: %{{.*}} = affine.apply [[MAP0]](%{{.*}})
-// CHECK-NEXT: %{{.*}} = affine.apply [[MAP1]](%{{.*}})
-// CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[%{{.*}}, %{{.*}}] : memref<16x4xf32>
-// CHECK-NEXT: %{{.*}} = affine.apply [[MAP2]](%{{.*}}, %{{.*}})
+// CHECK-NEXT: affine.apply [[MAP0]](%{{.*}})
+// CHECK-NEXT: affine.apply [[MAP1]](%{{.*}})
+// CHECK-NEXT: affine.load %{{.*}}[%{{.*}}, %{{.*}}] : memref<16x4xf32>
+// CHECK-NEXT: affine.apply [[MAP2]](%{{.*}}, %{{.*}})
// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[0] : memref<1xf32>
-// CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[0] : memref<1xf32>
+// CHECK-NEXT: affine.load %{{.*}}[0] : memref<1xf32>
// CHECK-NEXT: "foo"(%{{.*}}) : (f32) -> ()
// CHECK-NEXT: }
// CHECK-NEXT: return
@@ -643,29 +639,29 @@ func @R6_to_R2_reshape_square() -> memref<64x9xi32> {
//
// CHECK-LABEL: func @R6_to_R2_reshape
-// CHECK: %{{.*}} = alloc() : memref<1x2x3x3x16x1xi32>
-// CHECK: %{{.*}} = alloc() : memref<1x1xi32>
-// CHECK: %{{.*}} = alloc() : memref<64x9xi32>
+// CHECK: alloc() : memref<1x2x3x3x16x1xi32>
+// CHECK: alloc() : memref<1x1xi32>
+// CHECK: alloc() : memref<64x9xi32>
// CHECK-NEXT: affine.for %{{.*}} = 0 to 64 {
// CHECK-NEXT: affine.for %{{.*}} = 0 to 9 {
-// CHECK-NEXT: %{{.*}} = affine.apply [[MAP0]](%{{.*}}, %{{.*}})
-// CHECK-NEXT: %{{.*}} = affine.apply [[MAP1]](%{{.*}}, %{{.*}})
-// CHECK-NEXT: %{{.*}} = affine.apply [[MAP2]](%{{.*}}, %{{.*}})
-// CHECK-NEXT: %{{.*}} = affine.apply [[MAP3]](%{{.*}}, %{{.*}})
-// CHECK-NEXT: %{{.*}} = affine.apply [[MAP4]](%{{.*}}, %{{.*}})
-// CHECK-NEXT: %{{.*}} = "foo"(%{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}) : (index, index, index, index, index, index) -> i32
+// CHECK-NEXT: affine.apply [[MAP0]](%{{.*}}, %{{.*}})
+// CHECK-NEXT: affine.apply [[MAP1]](%{{.*}}, %{{.*}})
+// CHECK-NEXT: affine.apply [[MAP2]](%{{.*}}, %{{.*}})
+// CHECK-NEXT: affine.apply [[MAP3]](%{{.*}}, %{{.*}})
+// CHECK-NEXT: affine.apply [[MAP4]](%{{.*}}, %{{.*}})
+// CHECK-NEXT: "foo"(%{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}) : (index, index, index, index, index, index) -> i32
// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[0, ((%{{.*}} * 9 + %{{.*}}) mod 288) floordiv 144, (((%{{.*}} * 9 + %{{.*}}) mod 288) mod 144) floordiv 48, ((((%{{.*}} * 9 + %{{.*}}) mod 288) mod 144) mod 48) floordiv 16, ((((%{{.*}} * 9 + %{{.*}}) mod 288) mod 144) mod 48) mod 16, 0] : memref<1x2x3x3x16x1xi32>
-// CHECK-NEXT: %{{.*}} = affine.apply [[MAP11]](%{{.*}}, %{{.*}})
-// CHECK-NEXT: %{{.*}} = affine.apply [[MAP12]](%{{.*}})
-// CHECK-NEXT: %{{.*}} = affine.apply [[MAP13]](%{{.*}})
-// CHECK-NEXT: %{{.*}} = affine.apply [[MAP14]](%{{.*}})
-// CHECK-NEXT: %{{.*}} = affine.apply [[MAP15]](%{{.*}})
-// CHECK-NEXT: %{{.*}} = affine.apply [[MAP16]](%{{.*}})
-// CHECK-NEXT: %{{.*}} = affine.apply [[MAP17]](%{{.*}})
-// CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[0, ((%{{.*}} * 9 + %{{.*}}) mod 288) floordiv 144, (((%{{.*}} * 9 + %{{.*}}) mod 288) mod 144) floordiv 48, ((((%{{.*}} * 9 + %{{.*}}) mod 288) mod 144) mod 48) floordiv 16, ((((%{{.*}} * 9 + %{{.*}}) mod 288) mod 144) mod 48) mod 16, 0] : memref<1x2x3x3x16x1xi32>
+// CHECK-NEXT: affine.apply [[MAP11]](%{{.*}}, %{{.*}})
+// CHECK-NEXT: affine.apply [[MAP12]](%{{.*}})
+// CHECK-NEXT: affine.apply [[MAP13]](%{{.*}})
+// CHECK-NEXT: affine.apply [[MAP14]](%{{.*}})
+// CHECK-NEXT: affine.apply [[MAP15]](%{{.*}})
+// CHECK-NEXT: affine.apply [[MAP16]](%{{.*}})
+// CHECK-NEXT: affine.apply [[MAP17]](%{{.*}})
+// CHECK-NEXT: affine.load %{{.*}}[0, ((%{{.*}} * 9 + %{{.*}}) mod 288) floordiv 144, (((%{{.*}} * 9 + %{{.*}}) mod 288) mod 144) floordiv 48, ((((%{{.*}} * 9 + %{{.*}}) mod 288) mod 144) mod 48) floordiv 16, ((((%{{.*}} * 9 + %{{.*}}) mod 288) mod 144) mod 48) mod 16, 0] : memref<1x2x3x3x16x1xi32>
// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[0, 0] : memref<1x1xi32>
-// CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[0, 0] : memref<1x1xi32>
-// CHECK-NEXT: %{{.*}} = muli %{{.*}}, %{{.*}} : i32
+// CHECK-NEXT: affine.load %{{.*}}[0, 0] : memref<1x1xi32>
+// CHECK-NEXT: muli %{{.*}}, %{{.*}} : i32
// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[%{{.*}}, %{{.*}}] : memref<64x9xi32>
// CHECK-NEXT: }
// CHECK-NEXT: }
@@ -689,8 +685,7 @@ func @fuse_symbolic_bounds(%M : index, %N : index) {
affine.for %i2 = 0 to %M {
affine.for %i3 = 0 to %N {
- %idy = affine.apply affine_map<(d0)[s0] -> (d0 + s0)> (%i3)[%s]
- %v = affine.load %m[%i2, %idy] : memref<? x ? x f32>
+ %v = affine.load %m[%i2, %i3 + symbol(%s)] : memref<? x ? x f32>
}
}
@@ -699,8 +694,8 @@ func @fuse_symbolic_bounds(%M : index, %N : index) {
// -----
-// CHECK-LABEL: func @should_fuse_reduction_at_depth1
-func @should_fuse_reduction_at_depth1() {
+// CHECK-LABEL: func @should_fuse_reduction_at_depth_of_one
+func @should_fuse_reduction_at_depth_of_one() {
%a = alloc() : memref<10x100xf32>
%b = alloc() : memref<10xf32>
@@ -726,15 +721,15 @@ func @should_fuse_reduction_at_depth1() {
// memory space.
// CHECK: affine.for %{{.*}} = 0 to 10 {
// CHECK-NEXT: affine.for %{{.*}} = 0 to 100 {
- // CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[0] : memref<1xf32>
- // CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[%{{.*}}, %{{.*}}] : memref<10x100xf32>
- // CHECK-NEXT: %{{.*}} = "maxf"(%{{.*}}, %{{.*}}) : (f32, f32) -> f32
+ // CHECK-NEXT: affine.load %{{.*}}[0] : memref<1xf32>
+ // CHECK-NEXT: affine.load %{{.*}}[%{{.*}}, %{{.*}}] : memref<10x100xf32>
+ // CHECK-NEXT: "maxf"(%{{.*}}, %{{.*}}) : (f32, f32) -> f32
// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[0] : memref<1xf32>
// CHECK-NEXT: }
// CHECK-NEXT: affine.for %{{.*}} = 0 to 100 {
- // CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[0] : memref<1xf32>
- // CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[%{{.*}}, %{{.*}}] : memref<10x100xf32>
- // CHECK-NEXT: %{{.*}} = subf %{{.*}}, %{{.*}} : f32
+ // CHECK-NEXT: affine.load %{{.*}}[0] : memref<1xf32>
+ // CHECK-NEXT: affine.load %{{.*}}[%{{.*}}, %{{.*}}] : memref<10x100xf32>
+ // CHECK-NEXT: subf %{{.*}}, %{{.*}} : f32
// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[0] : memref<1xf32>
// CHECK-NEXT: }
// CHECK-NEXT: }
@@ -773,7 +768,7 @@ func @should_fuse_at_src_depth1_and_dst_depth1() {
// at depth 1 and the slice should be inserted at depth 1.
// CHECK: affine.for %{{.*}} = 0 to 100 {
// CHECK-NEXT: affine.for %{{.*}} = 0 to 16 {
- // CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[%{{.*}}, %{{.*}}] : memref<100x16xf32>
+ // CHECK-NEXT: affine.load %{{.*}}[%{{.*}}, %{{.*}}] : memref<100x16xf32>
// CHECK-NEXT: "op0"(%{{.*}}) : (f32) -> ()
// CHECK-NEXT: }
// CHECK-NEXT: affine.for %{{.*}} = 0 to 16 {
@@ -781,7 +776,7 @@ func @should_fuse_at_src_depth1_and_dst_depth1() {
// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[0, %{{.*}}] : memref<1x16xf32>
// CHECK-NEXT: }
// CHECK-NEXT: affine.for %{{.*}} = 0 to 16 {
- // CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[0, %{{.*}}] : memref<1x16xf32>
+ // CHECK-NEXT: affine.load %{{.*}}[0, %{{.*}}] : memref<1x16xf32>
// CHECK-NEXT: "op2"(%{{.*}}) : (f32) -> ()
// CHECK-NEXT: }
// CHECK-NEXT: }
@@ -811,10 +806,10 @@ func @should_fuse_src_depth1_at_dst_depth2() {
// loop IVs, so we should slice at depth 1 and insert the slice at depth 2.
// CHECK: affine.for %{{.*}} = 0 to 10 {
// CHECK-NEXT: affine.for %{{.*}} = 0 to 10 {
- // CHECK-NEXT: %{{.*}} = affine.apply [[MAP0]](%{{.*}}, %{{.*}})
+ // CHECK-NEXT: affine.apply [[MAP0]](%{{.*}}, %{{.*}})
// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[0] : memref<1xf32>
- // CHECK-NEXT: %{{.*}} = affine.apply [[MAP0]](%{{.*}}, %{{.*}})
- // CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[0] : memref<1xf32>
+ // CHECK-NEXT: affine.apply [[MAP0]](%{{.*}}, %{{.*}})
+ // CHECK-NEXT: affine.load %{{.*}}[0] : memref<1xf32>
// CHECK-NEXT: }
// CHECK-NEXT: }
// CHECK-NEXT: return
@@ -836,10 +831,10 @@ func @fusion_at_depth0_not_currently_supported() {
}
// NOTE: Should shrink memref size to 1 element access by load in dst loop
// nest, and make the store in the slice store to the same element.
- // CHECK-DAG: %{{.*}} = alloc() : memref<1xf32>
+ // CHECK-DAG: alloc() : memref<1xf32>
// CHECK: affine.for %{{.*}} = 0 to 10 {
// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[0] : memref<1xf32>
- // CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[0] : memref<1xf32>
+ // CHECK-NEXT: affine.load %{{.*}}[0] : memref<1xf32>
// CHECK-NEXT: }
// CHECK-NEXT: return
return
@@ -908,7 +903,7 @@ func @should_fuse_deep_loop_nests() {
// bounds which are a function of the first four loops of destination loop nest,
// where the destination loops nests have been interchanged.
-// CHECK-DAG: %{{.*}} = alloc() : memref<1x1x1x1x16x10xf32, 2>
+// CHECK-DAG: alloc() : memref<1x1x1x1x16x10xf32, 2>
// CHECK: affine.for %{{.*}} = 0 to 3 {
// CHECK-NEXT: affine.for %{{.*}} = 0 to 3 {
// CHECK-NEXT: affine.for %{{.*}} = 0 to 2 {
@@ -917,7 +912,7 @@ func @should_fuse_deep_loop_nests() {
// CHECK-NEXT: affine.for %{{.*}} = 0 to 3 {
// CHECK-NEXT: affine.for %{{.*}} = 0 to 16 {
// CHECK-NEXT: affine.for %{{.*}} = 0 to 10 {
-// CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[%{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}] : memref<2x2x3x3x16x10xf32, 2>
+// CHECK-NEXT: affine.load %{{.*}}[%{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}] : memref<2x2x3x3x16x10xf32, 2>
// CHECK-NEXT: }
// CHECK-NEXT: }
// CHECK-NEXT: affine.for %{{.*}} = 0 to 16 {
@@ -929,12 +924,12 @@ func @should_fuse_deep_loop_nests() {
// CHECK-NEXT: affine.for %{{.*}} = 0 to 2 {
// CHECK-NEXT: affine.for %{{.*}} = 0 to 16 {
// CHECK-NEXT: affine.for %{{.*}} = 0 to 10 {
-// CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[%{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}] : memref<2x2x3x3x16x10xf32, 2>
+// CHECK-NEXT: affine.load %{{.*}}[%{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}] : memref<2x2x3x3x16x10xf32, 2>
// CHECK-NEXT: }
// CHECK-NEXT: }
// CHECK-NEXT: affine.for %{{.*}} = 0 to 16 {
// CHECK-NEXT: affine.for %{{.*}} = 0 to 10 {
-// CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[0, 0, 0, 0, %{{.*}}, %{{.*}}] : memref<1x1x1x1x16x10xf32, 2>
+// CHECK-NEXT: affine.load %{{.*}}[0, 0, 0, 0, %{{.*}}, %{{.*}}] : memref<1x1x1x1x16x10xf32, 2>
// CHECK-NEXT: }
// CHECK-NEXT: }
// CHECK-NEXT: }
@@ -982,16 +977,16 @@ func @should_fuse_at_depth1_and_reduce_slice_trip_count() {
// NOTE: the size of the private memref created for the fused loop nest
// is reduced from the original shape from 4x256 to 4x16 because of the
// data accessed by the load.
- // CHECK-DAG: %{{.*}} = alloc() : memref<1x16xf32>
+ // CHECK-DAG: alloc() : memref<1x16xf32>
// CHECK: affine.for %{{.*}} = 0 to 4 {
// CHECK-NEXT: affine.for %{{.*}} = 0 to 256 {
- // CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[%{{.*}}, %{{.*}}] : memref<4x256xf32>
+ // CHECK-NEXT: affine.load %{{.*}}[%{{.*}}, %{{.*}}] : memref<4x256xf32>
// CHECK-NEXT: }
// CHECK-NEXT: affine.for %{{.*}} = 0 to 16 {
// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[0, %{{.*}}] : memref<1x16xf32>
// CHECK-NEXT: }
// CHECK-NEXT: affine.for %{{.*}} = 0 to 16 {
- // CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[0, %{{.*}}] : memref<1x16xf32>
+ // CHECK-NEXT: affine.load %{{.*}}[0, %{{.*}}] : memref<1x16xf32>
// CHECK-NEXT: }
// CHECK-NEXT: }
// CHECK-NEXT: return
@@ -1021,17 +1016,17 @@ func @should_fuse_at_depth1_with_trip_count_20() {
}
}
// NOTE: The size of the private memref created for fusion is shrunk to 20xf32
- // CHECK-DAG: %{{.*}} = alloc() : memref<20xf32>
+ // CHECK-DAG: alloc() : memref<20xf32>
// CHECK: affine.for %{{.*}} = 0 to 5 {
// CHECK-NEXT: affine.for %{{.*}} = 0 to 20 {
// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[%{{.*}}] : memref<20xf32>
// CHECK-NEXT: }
// CHECK-NEXT: affine.for %{{.*}} = 0 to 10 {
- // CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[%{{.*}}] : memref<20xf32>
+ // CHECK-NEXT: affine.load %{{.*}}[%{{.*}}] : memref<20xf32>
// CHECK-NEXT: }
// CHECK-NEXT: affine.for %{{.*}} = 0 to 10 {
// CHECK-NEXT: affine.for %{{.*}} = 0 to 20 {
- // CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[%{{.*}}] : memref<20xf32>
+ // CHECK-NEXT: affine.load %{{.*}}[%{{.*}}] : memref<20xf32>
// CHECK-NEXT: }
// CHECK-NEXT: }
// CHECK-NEXT: }
@@ -1062,17 +1057,17 @@ func @should_fuse_at_depth1_with_trip_count_19() {
}
}
// NOTE: The size of the private memref created for fusion is shrunk to 19xf32
- // CHECK-DAG: %{{.*}} = alloc() : memref<19xf32>
+ // CHECK-DAG: alloc() : memref<19xf32>
// CHECK: affine.for %{{.*}} = 0 to 5 {
// CHECK-NEXT: affine.for %{{.*}} = 0 to 19 {
// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[%{{.*}}] : memref<19xf32>
// CHECK-NEXT: }
// CHECK-NEXT: affine.for %{{.*}} = 0 to 19 {
- // CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[%{{.*}}] : memref<19xf32>
+ // CHECK-NEXT: affine.load %{{.*}}[%{{.*}}] : memref<19xf32>
// CHECK-NEXT: }
// CHECK-NEXT: affine.for %{{.*}} = 0 to 10 {
// CHECK-NEXT: affine.for %{{.*}} = 0 to 10 {
- // CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[%{{.*}}] : memref<19xf32>
+ // CHECK-NEXT: affine.load %{{.*}}[%{{.*}}] : memref<19xf32>
// CHECK-NEXT: }
// CHECK-NEXT: }
// CHECK-NEXT: }
@@ -1099,15 +1094,15 @@ func @should_fuse_with_private_memrefs_with_
diff _shapes() {
}
// Should create two new private memrefs customized to the shapes accessed
// by loops %{{.*}} and %{{.*}}.
- // CHECK-DAG: %{{.*}} = alloc() : memref<1xf32>
- // CHECK-DAG: %{{.*}} = alloc() : memref<1xf32>
+ // CHECK-DAG: alloc() : memref<1xf32>
+ // CHECK-DAG: alloc() : memref<1xf32>
// CHECK: affine.for %{{.*}} = 0 to 17 {
// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[0] : memref<1xf32>
- // CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[0] : memref<1xf32>
+ // CHECK-NEXT: affine.load %{{.*}}[0] : memref<1xf32>
// CHECK-NEXT: }
// CHECK-NEXT: affine.for %{{.*}} = 0 to 82 {
// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[0] : memref<1xf32>
- // CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[0] : memref<1xf32>
+ // CHECK-NEXT: affine.load %{{.*}}[0] : memref<1xf32>
// CHECK-NEXT: }
// CHECK-NEXT: return
return
@@ -1134,7 +1129,7 @@ func @should_not_fuse_live_out_arg(%arg0: memref<10xf32>) {
// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[%{{.*}}] : memref<10xf32>
// CHECK-NEXT: }
// CHECK-NEXT: affine.for %{{.*}} = 0 to 9 {
- // CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[%{{.*}}] : memref<10xf32>
+ // CHECK-NEXT: affine.load %{{.*}}[%{{.*}}] : memref<10xf32>
// CHECK-NEXT: }
// CHECK-NEXT: return
return
@@ -1157,7 +1152,7 @@ func @should_fuse_live_out_arg(%arg0: memref<10xf32>) {
// CHECK: affine.for %{{.*}} = 0 to 10 {
// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[%{{.*}}] : memref<10xf32>
- // CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[%{{.*}}] : memref<10xf32>
+ // CHECK-NEXT: affine.load %{{.*}}[%{{.*}}] : memref<10xf32>
// CHECK-NEXT: }
// CHECK-NEXT: return
return
@@ -1176,13 +1171,13 @@ func @should_not_fuse_escaping_memref() -> memref<10xf32> {
%v0 = affine.load %m[%i1] : memref<10xf32>
}
// This tests that the loop nest '%{{.*}}' should not be removed after fusion
- // because it writes to memref '%{{.*}}' which is returned by the function.
- // CHECK-DAG: %{{.*}} = alloc() : memref<10xf32>
+ // because it writes to memref '%{{.*}}' which is returned by the function.
+ // CHECK-DAG: alloc() : memref<10xf32>
// CHECK: affine.for %{{.*}} = 0 to 10 {
// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[%{{.*}}] : memref<10xf32>
// CHECK-NEXT: }
// CHECK-NEXT: affine.for %{{.*}} = 0 to 9 {
- // CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[%{{.*}}] : memref<10xf32>
+ // CHECK-NEXT: affine.load %{{.*}}[%{{.*}}] : memref<10xf32>
// CHECK-NEXT: }
// CHECK-NEXT: return %{{.*}} : memref<10xf32>
return %m : memref<10xf32>
@@ -1220,15 +1215,15 @@ func @R3_to_R2_reshape() {
// CHECK-DAG: [[MAP2:#map[0-9]+]] = affine_map<(d0) -> (d0 floordiv 48)>
// CHECK-LABEL: func @R3_to_R2_reshape()
-// CHECK-DAG: %{{.*}} = alloc() : memref<1x1x1xi32>
+// CHECK-DAG: alloc() : memref<1x1x1xi32>
// CHECK: affine.for %{{.*}} = 0 to 32 {
// CHECK-NEXT: affine.for %{{.*}} = 0 to 3 {
-// CHECK-NEXT: %{{.*}} = affine.apply [[MAP0]](%{{.*}}, %{{.*}})
-// CHECK-NEXT: %{{.*}} = "foo"(%{{.*}}, %{{.*}}, %{{.*}}) : (index, index, index) -> i32
+// CHECK-NEXT: affine.apply [[MAP0]](%{{.*}}, %{{.*}})
+// CHECK-NEXT: "foo"(%{{.*}}, %{{.*}}, %{{.*}}) : (index, index, index) -> i32
// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[0, 0, 0] : memref<1x1x1xi32>
-// CHECK-NEXT: %{{.*}} = affine.apply [[MAP1]](%{{.*}}, %{{.*}})
-// CHECK-NEXT: %{{.*}} = affine.apply [[MAP2]](%{{.*}})
-// CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[0, 0, 0] : memref<1x1x1xi32>
+// CHECK-NEXT: affine.apply [[MAP1]](%{{.*}}, %{{.*}})
+// CHECK-NEXT: affine.apply [[MAP2]](%{{.*}})
+// CHECK-NEXT: affine.load %{{.*}}[0, 0, 0] : memref<1x1x1xi32>
// CHECK-NEXT: }
// CHECK-NEXT: }
// CHECK-NEXT: return
@@ -1255,8 +1250,8 @@ func @should_not_fuse_multi_output_producer() {
// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[%{{.*}}] : memref<10xf32>
// CHECK-NEXT: }
// CHECK-NEXT: affine.for %{{.*}} = 0 to 10 {
- // CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[%{{.*}}] : memref<10xf32>
- // CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[%{{.*}}] : memref<10xf32>
+ // CHECK-NEXT: affine.load %{{.*}}[%{{.*}}] : memref<10xf32>
+ // CHECK-NEXT: affine.load %{{.*}}[%{{.*}}] : memref<10xf32>
// CHECK-NEXT: }
// CHECK-NEXT: return
return
@@ -1288,15 +1283,15 @@ func @fusion_preventing_deps_on_middle_loop() {
// '%b', because of the WAR dep from '%i0' to '%i1' on memref '%a' and
// because of the WAR dep from '%i1' to '%i2' on memref '%c'.
// CHECK: affine.for %{{.*}} = 0 to 10 {
- // CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[%{{.*}}] : memref<10xf32>
+ // CHECK-NEXT: affine.load %{{.*}}[%{{.*}}] : memref<10xf32>
// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[%{{.*}}] : memref<10xf32>
// CHECK-NEXT: }
// CHECK-NEXT: affine.for %{{.*}} = 0 to 10 {
// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[%{{.*}}] : memref<10xf32>
- // CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[%{{.*}}] : memref<10xf32>
+ // CHECK-NEXT: affine.load %{{.*}}[%{{.*}}] : memref<10xf32>
// CHECK-NEXT: }
// CHECK-NEXT: affine.for %{{.*}} = 0 to 10 {
- // CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[%{{.*}}] : memref<10xf32>
+ // CHECK-NEXT: affine.load %{{.*}}[%{{.*}}] : memref<10xf32>
// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[%{{.*}}] : memref<10xf32>
// CHECK-NEXT: }
// CHECK-NEXT: return
@@ -1341,14 +1336,14 @@ func @should_fuse_and_move_to_preserve_war_dep() {
// It is possible to fuse loop '%i0' into '%i3' and preserve dependences
// if the fused loop nest is inserted between loops '%i1' and '%i2'.
- // CHECK-DAG: %{{.*}} = alloc() : memref<1xf32>
+ // CHECK-DAG: alloc() : memref<1xf32>
// CHECK: affine.for %{{.*}} = 0 to 3 {
- // CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[%{{.*}}] : memref<10xf32>
+ // CHECK-NEXT: affine.load %{{.*}}[%{{.*}}] : memref<10xf32>
// CHECK-NEXT: }
// CHECK-NEXT: affine.for %{{.*}} = 0 to 10 {
- // CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[%{{.*}}] : memref<10xf32>
+ // CHECK-NEXT: affine.load %{{.*}}[%{{.*}}] : memref<10xf32>
// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[0] : memref<1xf32>
- // CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[0] : memref<1xf32>
+ // CHECK-NEXT: affine.load %{{.*}}[0] : memref<1xf32>
// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[%{{.*}}] : memref<10xf32>
// CHECK-NEXT: }
// CHECK-NEXT: affine.for %{{.*}} = 0 to 5 {
@@ -1384,7 +1379,7 @@ func @fusion_preventing_dep_on_constant() {
// '%a', because of the WAR dep from '%i0' to '%i1' on memref '%b' and
// because of the SSA value dep from '%cf11' def to use in '%i2'.
// CHECK: affine.for %{{.*}} = 0 to 10 {
- // CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[%{{.*}}] : memref<10xf32>
+ // CHECK-NEXT: affine.load %{{.*}}[%{{.*}}] : memref<10xf32>
// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[%{{.*}}] : memref<10xf32>
// CHECK-NEXT: }
// CHECK-NEXT: affine.for %{{.*}} = 0 to 10 {
@@ -1392,7 +1387,7 @@ func @fusion_preventing_dep_on_constant() {
// CHECK-NEXT: }
// CHECK-NEXT: %{{.*}} = constant 1.100000e+01 : f32
// CHECK-NEXT: affine.for %{{.*}} = 0 to 10 {
- // CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[%{{.*}}] : memref<10xf32>
+ // CHECK-NEXT: affine.load %{{.*}}[%{{.*}}] : memref<10xf32>
// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[%{{.*}}] : memref<10xf32>
// CHECK-NEXT: }
// CHECK-NEXT: return
@@ -1425,11 +1420,11 @@ func @should_fuse_and_preserve_dep_on_constant() {
// '%a', and preserve the WAR dep from '%i0' to '%i1' on memref '%b', and
// the SSA value dep from '%cf11' def to use in '%i2'.
- // CHECK: %{{.*}} = constant 1.100000e+01 : f32
+ // CHECK: constant 1.100000e+01 : f32
// CHECK-NEXT: affine.for %{{.*}} = 0 to 10 {
- // CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[%{{.*}}] : memref<10xf32>
+ // CHECK-NEXT: affine.load %{{.*}}[%{{.*}}] : memref<10xf32>
// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[0] : memref<1xf32>
- // CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[0] : memref<1xf32>
+ // CHECK-NEXT: affine.load %{{.*}}[0] : memref<1xf32>
// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[%{{.*}}] : memref<10xf32>
// CHECK-NEXT: }
// CHECK-NEXT: affine.for %{{.*}} = 0 to 10 {
@@ -1441,9 +1436,6 @@ func @should_fuse_and_preserve_dep_on_constant() {
// -----
-// CHECK: [[MAP2:#map[0-9]+]] = affine_map<(d0, d1) -> (d0 * 16 - d1 + 15)>
-// CHECK: [[MAP3:#map[0-9]+]] = affine_map<(d0, d1) -> (d0 * 16 + d1)>
-
// CHECK-LABEL: func @should_fuse_at_depth_above_loop_carried_dependence(%{{.*}}: memref<64x4xf32>, %{{.*}}: memref<64x4xf32>) {
func @should_fuse_at_depth_above_loop_carried_dependence(%arg0: memref<64x4xf32>, %arg1: memref<64x4xf32>) {
%out = alloc() : memref<64x4xf32>
@@ -1456,22 +1448,19 @@ func @should_fuse_at_depth_above_loop_carried_dependence(%arg0: memref<64x4xf32>
affine.for %i2 = 0 to 4 {
affine.for %i3 = 0 to 4 {
affine.for %i4 = 0 to 16 {
- %1 = affine.apply affine_map<(d0, d1) -> (d0 * 16 - d1 + 15)>(%i3, %i4)
- %2 = affine.load %arg1[%1, %i2] : memref<64x4xf32>
- "op0"(%2) : (f32) -> ()
+ %v = affine.load %arg1[16 * %i3 - %i4 + 15, %i2] : memref<64x4xf32>
+ "op0"(%v) : (f32) -> ()
}
affine.for %i5 = 0 to 4 {
affine.for %i6 = 0 to 16 {
- %3 = affine.apply affine_map<(d0, d1) -> (d0 * 16 - d1 + 15)>(%i5, %i6)
- %4 = affine.load %arg0[%3, %i3] : memref<64x4xf32>
- "op1"(%4) : (f32) -> ()
+ %v = affine.load %arg0[16 * %i5 - %i6 + 15, %i3] : memref<64x4xf32>
+ "op1"(%v) : (f32) -> ()
}
affine.for %i7 = 0 to 16 {
- %5 = "op2"() : () -> (f32)
- %6 = affine.apply affine_map<(d0, d1) -> (d0 * 16 + d1)>(%i5, %i7)
- %7 = affine.load %out[%6, %i2] : memref<64x4xf32>
- %8 = addf %7, %5 : f32
- affine.store %8, %out[%6, %i2] : memref<64x4xf32>
+ %r = "op2"() : () -> (f32)
+ %v = affine.load %out[16 * %i5 + %i7, %i2] : memref<64x4xf32>
+ %s = addf %v, %r : f32
+ affine.store %s, %out[16 * %i5 + %i7, %i2] : memref<64x4xf32>
}
}
}
@@ -1485,29 +1474,26 @@ func @should_fuse_at_depth_above_loop_carried_dependence(%arg0: memref<64x4xf32>
// loop nest iteration bounds on its loop '%i1' are reduced to 1, so the
// memref size can be reduced to 128x1xf32.
- // CHECK: %{{.*}} = alloc() : memref<64x1xf32>
+ // CHECK: alloc() : memref<64x1xf32>
// CHECK: affine.for %{{.*}} = 0 to 4 {
// CHECK-NEXT: affine.for %{{.*}} = 0 to 64 {
// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[%{{.*}}, 0] : memref<64x1xf32>
// CHECK-NEXT: }
// CHECK-NEXT: affine.for %{{.*}} = 0 to 4 {
// CHECK-NEXT: affine.for %{{.*}} = 0 to 16 {
- // CHECK-NEXT: %{{.*}} = affine.apply [[MAP2]](%{{.*}}, %{{.*}})
- // CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[%{{.*}}, %{{.*}}] : memref<64x4xf32>
+ // CHECK-NEXT: affine.load %{{.*}}[%{{.*}} * 16 - %{{.*}} + 15, %{{.*}}] : memref<64x4xf32>
// CHECK-NEXT: "op0"(%{{.*}}) : (f32) -> ()
// CHECK-NEXT: }
// CHECK-NEXT: affine.for %{{.*}} = 0 to 4 {
// CHECK-NEXT: affine.for %{{.*}} = 0 to 16 {
- // CHECK-NEXT: %{{.*}} = affine.apply [[MAP2]](%{{.*}}, %{{.*}})
- // CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[%{{.*}}, %{{.*}}] : memref<64x4xf32>
+ // CHECK-NEXT: affine.load %{{.*}}[%{{.*}} * 16 - %{{.*}} + 15, %{{.*}}] : memref<64x4xf32>
// CHECK-NEXT: "op1"(%{{.*}}) : (f32) -> ()
// CHECK-NEXT: }
// CHECK-NEXT: affine.for %{{.*}} = 0 to 16 {
// CHECK-NEXT: %{{.*}} = "op2"() : () -> f32
- // CHECK-NEXT: %{{.*}} = affine.apply [[MAP3]](%{{.*}}, %{{.*}})
- // CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[%{{.*}} * 16 + %{{.*}}, 0] : memref<64x1xf32>
- // CHECK-NEXT: %{{.*}} = addf %{{.*}}, %{{.*}} : f32
- // CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[%{{.*}} * 16 + %{{.*}}, 0] : memref<64x1xf32>
+ // CHECK: affine.load %{{.*}}[%{{.*}} * 16 + %{{.*}}, 0] : memref<64x1xf32>
+ // CHECK-NEXT: addf %{{.*}}, %{{.*}} : f32
+ // CHECK: affine.store %{{.*}}, %{{.*}}[%{{.*}} * 16 + %{{.*}}, 0] : memref<64x1xf32>
// CHECK-NEXT: }
// CHECK-NEXT: }
// CHECK-NEXT: }
@@ -1545,12 +1531,12 @@ func @should_fuse_after_private_memref_creation() {
// CHECK: affine.for %{{.*}} = 0 to 10 {
// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[0] : memref<1xf32>
- // CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[0] : memref<1xf32>
+ // CHECK-NEXT: affine.load %{{.*}}[0] : memref<1xf32>
// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[%{{.*}}] : memref<10xf32>
// CHECK-NEXT: }
// CHECK-NEXT: affine.for %{{.*}} = 0 to 10 {
// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[0] : memref<1xf32>
- // CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[0] : memref<1xf32>
+ // CHECK-NEXT: affine.load %{{.*}}[0] : memref<1xf32>
// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[%{{.*}}] : memref<10xf32>
// CHECK-NEXT: }
// CHECK-NEXT: return
@@ -1584,7 +1570,7 @@ func @should_fuse_after_one_loop_interchange() {
// CHECK: affine.for %{{.*}} = 0 to 10 {
// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[0] : memref<1xf32>
// CHECK-NEXT: affine.for %{{.*}} = 0 to 5 {
- // CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[0] : memref<1xf32>
+ // CHECK-NEXT: affine.load %{{.*}}[0] : memref<1xf32>
// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[0] : memref<1xf32>
// CHECK-NEXT: }
// CHECK-NEXT: }
@@ -1629,8 +1615,8 @@ func @should_fuse_after_two_loop_interchanges() {
// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[0, 0] : memref<1x1xf32>
// CHECK-NEXT: affine.for %{{.*}} = 0 to 4 {
// CHECK-NEXT: affine.for %{{.*}} = 0 to 2 {
- // CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[0, 0] : memref<1x1xf32>
- // CHECK-NEXT: %{{.*}} = addf %{{.*}}, %{{.*}} : f32
+ // CHECK-NEXT: affine.load %{{.*}}[0, 0] : memref<1x1xf32>
+ // CHECK-NEXT: addf %{{.*}}, %{{.*}} : f32
// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[0, 0] : memref<1x1xf32>
// CHECK-NEXT: }
// CHECK-NEXT: }
@@ -1656,7 +1642,7 @@ func @should_fuse_live_out_writer(%arg0 : memref<10xf32>) -> memref<10xf32> {
// CHECK: %{{.*}} = constant 0.000000e+00 : f32
// CHECK-NEXT: affine.for %{{.*}} = 0 to 10 {
// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[%{{.*}}] : memref<10xf32>
- // CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[%{{.*}}] : memref<10xf32>
+ // CHECK-NEXT: affine.load %{{.*}}[%{{.*}}] : memref<10xf32>
// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[%{{.*}}] : memref<10xf32>
// CHECK-NEXT: }
// CHECK-NEXT: return %{{.*}} : memref<10xf32>
@@ -1669,8 +1655,6 @@ func @should_fuse_live_out_writer(%arg0 : memref<10xf32>) -> memref<10xf32> {
// CHECK-DAG: [[MAP_LB:#map[0-9]+]] = affine_map<(d0) -> (d0 * 16)>
// CHECK-DAG: [[MAP_UB:#map[0-9]+]] = affine_map<(d0) -> (d0 * 16 + 16)>
-#map = affine_map<(d0, d1) -> (d0 * 16 + d1)>
-
// CHECK-LABEL: slice_tile
func @slice_tile(%arg0: memref<128x8xf32>, %arg1: memref<32x8xf32>, %0 : f32) -> memref<32x8xf32> {
affine.for %i0 = 0 to 32 {
@@ -1682,15 +1666,13 @@ func @slice_tile(%arg0: memref<128x8xf32>, %arg1: memref<32x8xf32>, %0 : f32) ->
affine.for %j = 0 to 8 {
affine.for %k = 0 to 8 {
affine.for %kk = 0 to 16 {
- %1 = affine.apply #map(%k, %kk)
- %2 = affine.load %arg0[%1, %j] : memref<128x8xf32>
- %3 = "foo"(%2) : (f32) -> f32
+ %v = affine.load %arg0[16 * %k + %kk, %j] : memref<128x8xf32>
+ %r = "foo"(%v) : (f32) -> f32
}
affine.for %ii = 0 to 16 {
- %6 = affine.apply #map(%i, %ii)
- %7 = affine.load %arg1[%6, %j] : memref<32x8xf32>
- %8 = addf %7, %7 : f32
- affine.store %8, %arg1[%6, %j] : memref<32x8xf32>
+ %v = affine.load %arg1[16 * %i + %ii, %j] : memref<32x8xf32>
+ %s = addf %v, %v : f32
+ affine.store %s, %arg1[16 * %i + %ii, %j] : memref<32x8xf32>
}
}
}
@@ -1704,15 +1686,13 @@ func @slice_tile(%arg0: memref<128x8xf32>, %arg1: memref<32x8xf32>, %0 : f32) ->
// CHECK-NEXT: }
// CHECK-NEXT: affine.for %{{.*}} = 0 to 8 {
// CHECK-NEXT: affine.for %{{.*}} = 0 to 16 {
-// CHECK-NEXT: %{{.*}} = affine.apply #map{{[0-9]+}}(%{{.*}}, %{{.*}})
-// CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[%{{.*}}, %{{.*}}] : memref<128x8xf32>
-// CHECK-NEXT: %{{.*}} = "foo"(%{{.*}}) : (f32) -> f32
+// CHECK-NEXT: affine.load %{{.*}}[%{{.*}} * 16 + %{{.*}}, %{{.*}}] : memref<128x8xf32>
+// CHECK-NEXT: "foo"(%{{.*}}) : (f32) -> f32
// CHECK-NEXT: }
// CHECK-NEXT: affine.for %{{.*}} = 0 to 16 {
-// CHECK-NEXT: %{{.*}} = affine.apply #map{{[0-9]+}}(%{{.*}}, %{{.*}})
-// CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[%{{.*}}, %{{.*}}] : memref<32x8xf32>
-// CHECK-NEXT: %{{.*}} = addf %{{.*}}, %{{.*}} : f32
-// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[%{{.*}}, %{{.*}}] : memref<32x8xf32>
+// CHECK-NEXT: affine.load %{{.*}}[%{{.*}} * 16 + %{{.*}}, %{{.*}}] : memref<32x8xf32>
+// CHECK-NEXT: addf %{{.*}}, %{{.*}} : f32
+// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[%{{.*}} * 16 + %{{.*}}, %{{.*}}] : memref<32x8xf32>
// CHECK-NEXT: }
// CHECK-NEXT: }
// CHECK-NEXT: }
@@ -1750,9 +1730,9 @@ func @test_add_slice_bounds() {
// CHECK: affine.for %{{.*}} = 0 to 10 {
// CHECK-NEXT: affine.for %{{.*}} = 0 to 10 {
// CHECK-NEXT: affine.for %{{.*}} = 0 to 10 {
-// CHECK-NEXT: %{{.*}} = affine.apply #map0(%{{.*}})
-// CHECK-NEXT: %{{.*}} = affine.apply #map0(%{{.*}})
-// CHECK-NEXT: %{{.*}} = affine.apply #map1(%{{.*}}, %{{.*}})
+// CHECK-NEXT: affine.apply #map0(%{{.*}})
+// CHECK-NEXT: affine.apply #map0(%{{.*}})
+// CHECK-NEXT: affine.apply #map1(%{{.*}}, %{{.*}})
// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[%{{.*}}] : memref<10xf32>
// CHECK-NEXT: }
// CHECK-NEXT: }
@@ -1760,7 +1740,7 @@ func @test_add_slice_bounds() {
// CHECK-NEXT: affine.for %{{.*}} = 0 to 10 {
// CHECK-NEXT: affine.for %{{.*}} = 0 to 10 {
// CHECK-NEXT: affine.for %{{.*}} = 0 to 10 {
-// CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[%{{.*}}] : memref<10xf32>
+// CHECK-NEXT: affine.load %{{.*}}[%{{.*}}] : memref<10xf32>
// CHECK-NEXT: }
// CHECK-NEXT: }
// CHECK-NEXT: }
@@ -1818,14 +1798,14 @@ func @should_fuse_init_loops_siblings_then_shared_producer(%arg0: memref<10x10xf
// CHECK-NEXT: affine.for %{{.*}} = 0 to 3 {
// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[0, 0] : memref<1x1xf32>
// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[%{{.*}}, %{{.*}}] : memref<10x10xf32>
-// CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[0, 0] : memref<1x1xf32>
-// CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[%{{.*}}, %{{.*}}] : memref<10x10xf32>
-// CHECK-NEXT: %{{.*}} = mulf %{{.*}}, %{{.*}} : f32
+// CHECK-NEXT: affine.load %{{.*}}[0, 0] : memref<1x1xf32>
+// CHECK-NEXT: affine.load %{{.*}}[%{{.*}}, %{{.*}}] : memref<10x10xf32>
+// CHECK-NEXT: mulf %{{.*}}, %{{.*}} : f32
// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[%{{.*}}, %{{.*}}] : memref<10x10xf32>
// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[%{{.*}}, %{{.*}}] : memref<10x10xf32>
-// CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[0, 0] : memref<1x1xf32>
-// CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[%{{.*}}, %{{.*}}] : memref<10x10xf32>
-// CHECK-NEXT: %{{.*}} = addf %{{.*}}, %{{.*}} : f32
+// CHECK-NEXT: affine.load %{{.*}}[0, 0] : memref<1x1xf32>
+// CHECK-NEXT: affine.load %{{.*}}[%{{.*}}, %{{.*}}] : memref<10x10xf32>
+// CHECK-NEXT: addf %{{.*}}, %{{.*}} : f32
// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[%{{.*}}, %{{.*}}] : memref<10x10xf32>
// CHECK-NEXT: }
// CHECK-NEXT: }
@@ -1878,19 +1858,19 @@ func @two_matrix_vector_products() {
// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[%{{.*}}, 0] : memref<10x1xf32>
// CHECK-NEXT: }
// CHECK-NEXT: affine.for %{{.*}} = 0 to 10 {
-// CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[%{{.*}}, 0] : memref<10x1xf32>
-// CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[%{{.*}}] : memref<10xf32>
-// CHECK-NEXT: %{{.*}} = mulf %{{.*}}, %{{.*}} : f32
-// CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[%{{.*}}] : memref<10xf32>
-// CHECK-NEXT: %{{.*}} = addf %{{.*}}, %{{.*}} : f32
+// CHECK-NEXT: affine.load %{{.*}}[%{{.*}}, 0] : memref<10x1xf32>
+// CHECK-NEXT: affine.load %{{.*}}[%{{.*}}] : memref<10xf32>
+// CHECK-NEXT: mulf %{{.*}}, %{{.*}} : f32
+// CHECK-NEXT: affine.load %{{.*}}[%{{.*}}] : memref<10xf32>
+// CHECK-NEXT: addf %{{.*}}, %{{.*}} : f32
// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[%{{.*}}] : memref<10xf32>
// CHECK-NEXT: }
// CHECK-NEXT: affine.for %{{.*}} = 0 to 10 {
-// CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[%{{.*}}, 0] : memref<10x1xf32>
-// CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[%{{.*}}] : memref<10xf32>
-// CHECK-NEXT: %{{.*}} = mulf %{{.*}}, %{{.*}} : f32
-// CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[%{{.*}}] : memref<10xf32>
-// CHECK-NEXT: %{{.*}} = addf %{{.*}}, %{{.*}} : f32
+// CHECK-NEXT: affine.load %{{.*}}[%{{.*}}, 0] : memref<10x1xf32>
+// CHECK-NEXT: affine.load %{{.*}}[%{{.*}}] : memref<10xf32>
+// CHECK-NEXT: mulf %{{.*}}, %{{.*}} : f32
+// CHECK-NEXT: affine.load %{{.*}}[%{{.*}}] : memref<10xf32>
+// CHECK-NEXT: addf %{{.*}}, %{{.*}} : f32
// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[%{{.*}}] : memref<10xf32>
// CHECK-NEXT: }
// CHECK-NEXT: }
@@ -1922,7 +1902,7 @@ func @should_not_slice_past_slice_barrier() {
// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[0, %{{.*}}] : memref<1x16xf32>
// CHECK-NEXT: } {slice_fusion_barrier = true}
// CHECK-NEXT: affine.for %{{.*}} = 0 to 16 {
-// CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[0, %{{.*}}] : memref<1x16xf32>
+// CHECK-NEXT: affine.load %{{.*}}[0, %{{.*}}] : memref<1x16xf32>
// CHECK-NEXT: "op2"(%{{.*}}) : (f32) -> ()
// CHECK-NEXT: }
// CHECK-NEXT: }
@@ -1957,15 +1937,15 @@ func @fuse_across_dim_mismatch(%arg0: memref<4x4x16x1xf32>, %arg1: memref<144x9x
}
// MAXIMAL: #map0 = affine_map<(d0, d1) -> (d0 * 16 + d1)>
// MAXIMAL-LABEL: func @fuse_across_dim_mismatch
-// MAXIMAL: %{{.*}} = alloc() : memref<1x1xf32>
+// MAXIMAL: alloc() : memref<1x1xf32>
// MAXIMAL: affine.for %{{.*}} = 0 to 9 {
// MAXIMAL-NEXT: affine.for %{{.*}} = 0 to 9 {
// MAXIMAL-NEXT: affine.for %{{.*}} = 0 to 4 {
// MAXIMAL-NEXT: affine.for %{{.*}} = 0 to 16 {
-// MAXIMAL-NEXT: %{{.*}} = affine.apply #map0(%{{.*}}, %{{.*}})
+// MAXIMAL-NEXT: affine.apply #map0(%{{.*}}, %{{.*}})
// MAXIMAL-NEXT: affine.store %{{.*}}, %{{.*}}[0, 0] : memref<1x1xf32>
-// MAXIMAL-NEXT: %{{.*}} = affine.apply #map0(%{{.*}}, %{{.*}})
-// MAXIMAL-NEXT: %{{.*}} = affine.load %{{.*}}[0, 0] : memref<1x1xf32>
+// MAXIMAL-NEXT: affine.apply #map0(%{{.*}}, %{{.*}})
+// MAXIMAL-NEXT: affine.load %{{.*}}[0, 0] : memref<1x1xf32>
// MAXIMAL-NEXT: }
// MAXIMAL-NEXT: }
// MAXIMAL-NEXT: }
@@ -2029,35 +2009,35 @@ func @fuse_across_varying_dims_complex(%arg0: f32) {
// MAXIMAL-DAG: [[MAP7:#map[0-9]+]] = affine_map<(d0, d1) -> (d0 * 16 + d1)>
// MAXIMAL-DAG: [[MAP8:#map[0-9]+]] = affine_map<(d0, d1) -> (d0 * 16 - d1 + 15)>
// MAXIMAL-LABEL: func @fuse_across_varying_dims_complex
-// MAXIMAL-NEXT: %{{.*}} = alloc() : memref<64x1xf32>
-// MAXIMAL-NEXT: %{{.*}} = constant 0 : index
-// MAXIMAL-NEXT: %{{.*}} = alloc() : memref<2x2x3x3x16x1xf32>
-// MAXIMAL-NEXT: %{{.*}} = alloc() : memref<144x4xf32>
+// MAXIMAL-NEXT: alloc() : memref<64x1xf32>
+// MAXIMAL-NEXT: constant 0 : index
+// MAXIMAL-NEXT: alloc() : memref<2x2x3x3x16x1xf32>
+// MAXIMAL-NEXT: alloc() : memref<144x4xf32>
// MAXIMAL-NEXT: affine.for %{{.*}} = 0 to 9 {
// MAXIMAL-NEXT: affine.for %{{.*}} = 0 to 9 {
// MAXIMAL-NEXT: affine.for %{{.*}} = 0 to 4 {
// MAXIMAL-NEXT: affine.for %{{.*}} = 0 to 16 {
// MAXIMAL-NEXT: affine.for %{{.*}} = 0 to 64 {
-// MAXIMAL-NEXT: %{{.*}} = affine.apply [[MAP0]](%{{.*}}, %{{.*}})
-// MAXIMAL-NEXT: %{{.*}} = affine.apply [[MAP1]](%{{.*}}, %{{.*}})
-// MAXIMAL-NEXT: %{{.*}} = affine.apply [[MAP2]](%{{.*}}, %{{.*}})
-// MAXIMAL-NEXT: %{{.*}} = affine.apply [[MAP3]](%{{.*}}, %{{.*}})
-// MAXIMAL-NEXT: %{{.*}} = affine.apply [[MAP4]](%{{.*}}, %{{.*}})
-// MAXIMAL-NEXT: %{{.*}} = affine.load %{{.*}}[%{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}] : memref<2x2x3x3x16x1xf32>
+// MAXIMAL-NEXT: affine.apply [[MAP0]](%{{.*}}, %{{.*}})
+// MAXIMAL-NEXT: affine.apply [[MAP1]](%{{.*}}, %{{.*}})
+// MAXIMAL-NEXT: affine.apply [[MAP2]](%{{.*}}, %{{.*}})
+// MAXIMAL-NEXT: affine.apply [[MAP3]](%{{.*}}, %{{.*}})
+// MAXIMAL-NEXT: affine.apply [[MAP4]](%{{.*}}, %{{.*}})
+// MAXIMAL-NEXT: affine.load %{{.*}}[%{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}] : memref<2x2x3x3x16x1xf32>
// MAXIMAL-NEXT: affine.store %{{.*}}, %{{.*}}[%{{.*}}, 0] : memref<64x1xf32>
// MAXIMAL-NEXT: }
// MAXIMAL-NEXT: affine.for %{{.*}} = 0 to 4 {
// MAXIMAL-NEXT: affine.for %{{.*}} = 0 to 16 {
-// MAXIMAL-NEXT: %{{.*}} = affine.apply [[MAP7]](%{{.*}}, %{{.*}})
-// MAXIMAL-NEXT: %{{.*}} = affine.load %{{.*}}[%{{.*}} * 16 + %{{.*}}, 0] : memref<64x1xf32>
+// MAXIMAL-NEXT: affine.apply [[MAP7]](%{{.*}}, %{{.*}})
+// MAXIMAL-NEXT: affine.load %{{.*}}[%{{.*}} * 16 + %{{.*}}, 0] : memref<64x1xf32>
// MAXIMAL-NEXT: }
// MAXIMAL-NEXT: affine.for %{{.*}} = 0 to 16 {
-// MAXIMAL-NEXT: %{{.*}} = affine.apply [[MAP7]](%{{.*}}, %{{.*}})
+// MAXIMAL-NEXT: affine.apply [[MAP7]](%{{.*}}, %{{.*}})
// MAXIMAL-NEXT: affine.store %{{.*}}, %{{.*}}[%{{.*}}, %{{.*}}] : memref<144x4xf32>
// MAXIMAL-NEXT: }
// MAXIMAL-NEXT: }
-// MAXIMAL-NEXT: %{{.*}} = affine.apply [[MAP8]](%{{.*}}, %{{.*}})
-// MAXIMAL-NEXT: %{{.*}} = affine.load %{{.*}}[%{{.*}} * 16 - %{{.*}} + 15, 0] : memref<64x1xf32>
+// MAXIMAL-NEXT: affine.apply [[MAP8]](%{{.*}}, %{{.*}})
+// MAXIMAL-NEXT: affine.load %{{.*}}[%{{.*}} * 16 - %{{.*}} + 15, 0] : memref<64x1xf32>
// MAXIMAL-NEXT: }
// MAXIMAL-NEXT: }
// MAXIMAL-NEXT: }
@@ -2089,9 +2069,9 @@ func @should_fuse_with_slice_union() {
// CHECK-NEXT: affine.for %{{.*}} = 10 to 25 {
// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[%{{.*}} - 10] : memref<15xf32>
// CHECK-NEXT: }
-// CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[%{{.*}} - 10] : memref<15xf32>
+// CHECK-NEXT: affine.load %{{.*}}[%{{.*}} - 10] : memref<15xf32>
// CHECK-NEXT: affine.for %{{.*}} = 15 to 25 {
-// CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[%{{.*}} - 10] : memref<15xf32>
+// CHECK-NEXT: affine.load %{{.*}}[%{{.*}} - 10] : memref<15xf32>
// CHECK-NEXT: }
// CHECK-NEXT: }
// CHECK-NEXT: return
@@ -2125,16 +2105,16 @@ func @affine_add_mm_fused(%arg0: memref<1024x1024xf32>, %arg1: memref<1024x1024x
// dependence between load/store on '%arg2', carried on reduction loop %i6.
// CHECK: affine.for %{{.*}} = 0 to 1024 {
// CHECK-NEXT: affine.for %{{.*}} = 0 to 1024 {
- // CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[%{{.*}}, %{{.*}}] : memref<1024x1024xf32>
- // CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[%{{.*}}, %{{.*}}] : memref<1024x1024xf32>
- // CHECK-NEXT: %{{.*}} = addf %{{.*}}, %{{.*}} : f32
+ // CHECK-NEXT: affine.load %{{.*}}[%{{.*}}, %{{.*}}] : memref<1024x1024xf32>
+ // CHECK-NEXT: affine.load %{{.*}}[%{{.*}}, %{{.*}}] : memref<1024x1024xf32>
+ // CHECK-NEXT: addf %{{.*}}, %{{.*}} : f32
// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[%{{.*}}, %{{.*}}] : memref<1024x1024xf32>
// CHECK-NEXT: affine.for %{{.*}} = 0 to 1024 {
- // CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[%{{.*}}, %{{.*}}] : memref<1024x1024xf32>
- // CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[%{{.*}}, %{{.*}}] : memref<1024x1024xf32>
- // CHECK-NEXT: %{{.*}} = mulf %{{.*}}, %{{.*}} : f32
- // CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[%{{.*}}, %{{.*}}] : memref<1024x1024xf32>
- // CHECK-NEXT: %{{.*}} = addf %{{.*}}, %{{.*}} : f32
+ // CHECK-NEXT: affine.load %{{.*}}[%{{.*}}, %{{.*}}] : memref<1024x1024xf32>
+ // CHECK-NEXT: affine.load %{{.*}}[%{{.*}}, %{{.*}}] : memref<1024x1024xf32>
+ // CHECK-NEXT: mulf %{{.*}}, %{{.*}} : f32
+ // CHECK-NEXT: affine.load %{{.*}}[%{{.*}}, %{{.*}}] : memref<1024x1024xf32>
+ // CHECK-NEXT: addf %{{.*}}, %{{.*}} : f32
// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[%{{.*}}, %{{.*}}] : memref<1024x1024xf32>
// CHECK-NEXT: }
// CHECK-NEXT: }
@@ -2188,22 +2168,22 @@ func @affine_2mm_fused(%arg0: memref<1024x1024xf32>, %arg1: memref<1024x1024xf32
// CHECK-NEXT: affine.for %{{.*}} = 0 to 1024 {
// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[%{{.*}}, %{{.*}}] : memref<1024x1024xf32>
// CHECK-NEXT: affine.for %{{.*}} = 0 to 1024 {
- // CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[%{{.*}}, %{{.*}}] : memref<1024x1024xf32>
- // CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[%{{.*}}, %{{.*}}] : memref<1024x1024xf32>
- // CHECK-NEXT: %{{.*}} = mulf %{{.*}}, %{{.*}} : f32
- // CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[%{{.*}}, %{{.*}}] : memref<1024x1024xf32>
- // CHECK-NEXT: %{{.*}} = addf %{{.*}}, %{{.*}} : f32
+ // CHECK-NEXT: affine.load %{{.*}}[%{{.*}}, %{{.*}}] : memref<1024x1024xf32>
+ // CHECK-NEXT: affine.load %{{.*}}[%{{.*}}, %{{.*}}] : memref<1024x1024xf32>
+ // CHECK-NEXT: mulf %{{.*}}, %{{.*}} : f32
+ // CHECK-NEXT: affine.load %{{.*}}[%{{.*}}, %{{.*}}] : memref<1024x1024xf32>
+ // CHECK-NEXT: addf %{{.*}}, %{{.*}} : f32
// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[%{{.*}}, %{{.*}}] : memref<1024x1024xf32>
// CHECK-NEXT: }
// CHECK-NEXT: }
// CHECK-NEXT: affine.for %{{.*}} = 0 to 1024 {
// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[%{{.*}}, %{{.*}}] : memref<1024x1024xf32>
// CHECK-NEXT: affine.for %{{.*}} = 0 to 1024 {
- // CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[%{{.*}}, %{{.*}}] : memref<1024x1024xf32>
- // CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[%{{.*}}, %{{.*}}] : memref<1024x1024xf32>
- // CHECK-NEXT: %{{.*}} = mulf %{{.*}}, %{{.*}} : f32
- // CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[%{{.*}}, %{{.*}}] : memref<1024x1024xf32>
- // CHECK-NEXT: %{{.*}} = addf %{{.*}}, %{{.*}} : f32
+ // CHECK-NEXT: affine.load %{{.*}}[%{{.*}}, %{{.*}}] : memref<1024x1024xf32>
+ // CHECK-NEXT: affine.load %{{.*}}[%{{.*}}, %{{.*}}] : memref<1024x1024xf32>
+ // CHECK-NEXT: mulf %{{.*}}, %{{.*}} : f32
+ // CHECK-NEXT: affine.load %{{.*}}[%{{.*}}, %{{.*}}] : memref<1024x1024xf32>
+ // CHECK-NEXT: addf %{{.*}}, %{{.*}} : f32
// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[%{{.*}}, %{{.*}}] : memref<1024x1024xf32>
// CHECK-NEXT: }
// CHECK-NEXT: }
@@ -2243,21 +2223,21 @@ func @affine_2_dependent_mm_fused(%arg0: memref<1024x1024xf32>, %arg1: memref<10
// CHECK: affine.for %{{.*}} = 0 to 1024 {
// CHECK-NEXT: affine.for %{{.*}} = 0 to 1024 {
// CHECK-NEXT: affine.for %{{.*}} = 0 to 1024 {
- // CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[%{{.*}}, %{{.*}}] : memref<1024x1024xf32>
- // CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[%{{.*}}, %{{.*}}] : memref<1024x1024xf32>
- // CHECK-NEXT: %{{.*}} = mulf %{{.*}}, %{{.*}} : f32
- // CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[%{{.*}}, %{{.*}}] : memref<1024x1024xf32>
- // CHECK-NEXT: %{{.*}} = addf %{{.*}}, %{{.*}} : f32
+ // CHECK-NEXT: affine.load %{{.*}}[%{{.*}}, %{{.*}}] : memref<1024x1024xf32>
+ // CHECK-NEXT: affine.load %{{.*}}[%{{.*}}, %{{.*}}] : memref<1024x1024xf32>
+ // CHECK-NEXT: mulf %{{.*}}, %{{.*}} : f32
+ // CHECK-NEXT: affine.load %{{.*}}[%{{.*}}, %{{.*}}] : memref<1024x1024xf32>
+ // CHECK-NEXT: addf %{{.*}}, %{{.*}} : f32
// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[%{{.*}}, %{{.*}}] : memref<1024x1024xf32>
// CHECK-NEXT: }
// CHECK-NEXT: }
// CHECK-NEXT: affine.for %{{.*}} = 0 to 1024 {
// CHECK-NEXT: affine.for %{{.*}} = 0 to 1024 {
- // CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[%{{.*}}, %{{.*}}] : memref<1024x1024xf32>
- // CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[%{{.*}}, %{{.*}}] : memref<1024x1024xf32>
- // CHECK-NEXT: %{{.*}} = mulf %{{.*}}, %{{.*}} : f32
- // CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[%{{.*}}, %{{.*}}] : memref<1024x1024xf32>
- // CHECK-NEXT: %{{.*}} = addf %{{.*}}, %{{.*}} : f32
+ // CHECK-NEXT: affine.load %{{.*}}[%{{.*}}, %{{.*}}] : memref<1024x1024xf32>
+ // CHECK-NEXT: affine.load %{{.*}}[%{{.*}}, %{{.*}}] : memref<1024x1024xf32>
+ // CHECK-NEXT: mulf %{{.*}}, %{{.*}} : f32
+ // CHECK-NEXT: affine.load %{{.*}}[%{{.*}}, %{{.*}}] : memref<1024x1024xf32>
+ // CHECK-NEXT: addf %{{.*}}, %{{.*}} : f32
// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[%{{.*}}, %{{.*}}] : memref<1024x1024xf32>
// CHECK-NEXT: }
// CHECK-NEXT: }
@@ -2376,14 +2356,14 @@ func @mul_add_0(%arg0: memref<3x4xf32>, %arg1: memref<4x3xf32>, %arg2: memref<3x
// CHECK-NEXT: affine.for %[[i2:.*]] = 0 to 4 {
// CHECK-NEXT: affine.load %{{.*}}[%[[i2]], %[[i1]]] : memref<4x3xf32>
// CHECK-NEXT: affine.load %{{.*}}[%[[i0]], %[[i2]]] : memref<3x4xf32>
- // CHECK-NEXT: %{{.*}} = mulf %{{.*}}, %{{.*}} : f32
+ // CHECK-NEXT: mulf %{{.*}}, %{{.*}} : f32
// CHECK-NEXT: affine.load %{{.*}}[0, 0] : memref<1x1xf32>
- // CHECK-NEXT: %{{.*}} = addf %{{.*}}, %{{.*}} : f32
+ // CHECK-NEXT: addf %{{.*}}, %{{.*}} : f32
// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[0, 0] : memref<1x1xf32>
// CHECK-NEXT: }
// CHECK-NEXT: affine.load %{{.*}}[%[[i0]], %[[i1]]] : memref<3x3xf32>
// CHECK-NEXT: affine.load %{{.*}}[0, 0] : memref<1x1xf32>
- // CHECK-NEXT: %{{.*}} = addf %{{.*}}, %{{.*}} : f32
+ // CHECK-NEXT: addf %{{.*}}, %{{.*}} : f32
// CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[%[[i0]], %[[i1]]] : memref<3x3xf32>
// CHECK-NEXT: }
// CHECK-NEXT: }
More information about the Mlir-commits
mailing list