2018-11-03 00:55:04 +08:00
|
|
|
// RUN: mlir-opt %s -memref-dependence-check -split-input-file -verify | FileCheck %s
|
|
|
|
|
2018-12-20 12:47:06 +08:00
|
|
|
// -----
|
|
|
|
|
|
|
|
#set0 = (d0) : (1 == 0)
|
|
|
|
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK-LABEL: func @store_may_execute_before_load() {
|
|
|
|
func @store_may_execute_before_load() {
|
2018-12-20 12:47:06 +08:00
|
|
|
%m = alloc() : memref<10xf32>
|
|
|
|
%cf7 = constant 7.0 : f32
|
|
|
|
%c0 = constant 4 : index
|
|
|
|
// There is a dependence from store 0 to load 1 at depth 1 because the
|
2019-01-29 13:23:53 +08:00
|
|
|
// ancestor IfOp of the store, dominates the ancestor ForSmt of the load,
|
2018-12-20 12:47:06 +08:00
|
|
|
// and thus the store "may" conditionally execute before the load.
|
2019-02-08 06:24:18 +08:00
|
|
|
if #set0(%c0) {
|
2019-02-07 13:54:18 +08:00
|
|
|
for %i0 = 0 to 10 {
|
2018-12-20 12:47:06 +08:00
|
|
|
store %cf7, %m[%i0] : memref<10xf32>
|
|
|
|
// expected-note@-1 {{dependence from 0 to 0 at depth 1 = false}}
|
|
|
|
// expected-note@-2 {{dependence from 0 to 0 at depth 2 = false}}
|
|
|
|
// expected-note@-3 {{dependence from 0 to 1 at depth 1 = true}}
|
|
|
|
}
|
|
|
|
}
|
2019-02-07 13:54:18 +08:00
|
|
|
for %i1 = 0 to 10 {
|
2018-12-20 12:47:06 +08:00
|
|
|
%v0 = load %m[%i1] : memref<10xf32>
|
|
|
|
// expected-note@-1 {{dependence from 1 to 1 at depth 1 = false}}
|
|
|
|
// expected-note@-2 {{dependence from 1 to 1 at depth 2 = false}}
|
|
|
|
// expected-note@-3 {{dependence from 1 to 0 at depth 1 = false}}
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK-LABEL: func @dependent_loops() {
|
|
|
|
func @dependent_loops() {
|
2018-12-20 12:47:06 +08:00
|
|
|
%0 = alloc() : memref<10xf32>
|
|
|
|
%cst = constant 7.000000e+00 : f32
|
|
|
|
// There is a dependence from 0 to 1 at depth 1 (common surrounding loops 0)
|
|
|
|
// because the first loop with the store dominates the second loop.
|
2019-02-07 13:54:18 +08:00
|
|
|
for %i0 = 0 to 10 {
|
2018-12-20 12:47:06 +08:00
|
|
|
store %cst, %0[%i0] : memref<10xf32>
|
|
|
|
// expected-note@-1 {{dependence from 0 to 0 at depth 1 = false}}
|
|
|
|
// expected-note@-2 {{dependence from 0 to 0 at depth 2 = false}}
|
|
|
|
// expected-note@-3 {{dependence from 0 to 1 at depth 1 = true}}
|
|
|
|
}
|
2019-02-07 13:54:18 +08:00
|
|
|
for %i1 = 0 to 10 {
|
2018-12-20 12:47:06 +08:00
|
|
|
%1 = load %0[%i1] : memref<10xf32>
|
|
|
|
// expected-note@-1 {{dependence from 1 to 1 at depth 1 = false}}
|
|
|
|
// expected-note@-2 {{dependence from 1 to 1 at depth 2 = false}}
|
|
|
|
// expected-note@-3 {{dependence from 1 to 0 at depth 1 = false}}
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2018-11-03 00:55:04 +08:00
|
|
|
// -----
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK-LABEL: func @different_memrefs() {
|
|
|
|
func @different_memrefs() {
|
2018-11-03 00:55:04 +08:00
|
|
|
%m.a = alloc() : memref<100xf32>
|
|
|
|
%m.b = alloc() : memref<100xf32>
|
|
|
|
%c0 = constant 0 : index
|
|
|
|
%c1 = constant 1.0 : f32
|
|
|
|
store %c1, %m.a[%c0] : memref<100xf32>
|
2018-11-10 01:42:24 +08:00
|
|
|
// expected-note@-1 {{dependence from 0 to 0 at depth 1 = false}}
|
|
|
|
// expected-note@-2 {{dependence from 0 to 1 at depth 1 = false}}
|
2018-11-03 00:55:04 +08:00
|
|
|
%v0 = load %m.b[%c0] : memref<100xf32>
|
2018-11-10 01:42:24 +08:00
|
|
|
// expected-note@-1 {{dependence from 1 to 0 at depth 1 = false}}
|
|
|
|
// expected-note@-2 {{dependence from 1 to 1 at depth 1 = false}}
|
2018-11-03 00:55:04 +08:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK-LABEL: func @store_load_different_elements() {
|
|
|
|
func @store_load_different_elements() {
|
2018-11-03 00:55:04 +08:00
|
|
|
%m = alloc() : memref<100xf32>
|
|
|
|
%c0 = constant 0 : index
|
|
|
|
%c1 = constant 1 : index
|
|
|
|
%c7 = constant 7.0 : f32
|
|
|
|
store %c7, %m[%c0] : memref<100xf32>
|
2018-11-10 01:42:24 +08:00
|
|
|
// expected-note@-1 {{dependence from 0 to 0 at depth 1 = false}}
|
|
|
|
// expected-note@-2 {{dependence from 0 to 1 at depth 1 = false}}
|
2018-11-03 00:55:04 +08:00
|
|
|
%v0 = load %m[%c1] : memref<100xf32>
|
2018-11-10 01:42:24 +08:00
|
|
|
// expected-note@-1 {{dependence from 1 to 0 at depth 1 = false}}
|
|
|
|
// expected-note@-2 {{dependence from 1 to 1 at depth 1 = false}}
|
2018-11-03 00:55:04 +08:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK-LABEL: func @load_store_different_elements() {
|
|
|
|
func @load_store_different_elements() {
|
2018-11-03 00:55:04 +08:00
|
|
|
%m = alloc() : memref<100xf32>
|
|
|
|
%c0 = constant 0 : index
|
|
|
|
%c1 = constant 1 : index
|
|
|
|
%c7 = constant 7.0 : f32
|
|
|
|
%v0 = load %m[%c1] : memref<100xf32>
|
2018-11-10 01:42:24 +08:00
|
|
|
// expected-note@-1 {{dependence from 0 to 0 at depth 1 = false}}
|
|
|
|
// expected-note@-2 {{dependence from 0 to 1 at depth 1 = false}}
|
2018-11-03 00:55:04 +08:00
|
|
|
store %c7, %m[%c0] : memref<100xf32>
|
2018-11-10 01:42:24 +08:00
|
|
|
// expected-note@-1 {{dependence from 1 to 0 at depth 1 = false}}
|
|
|
|
// expected-note@-2 {{dependence from 1 to 1 at depth 1 = false}}
|
2018-11-03 00:55:04 +08:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK-LABEL: func @store_load_same_element() {
|
|
|
|
func @store_load_same_element() {
|
2018-11-03 00:55:04 +08:00
|
|
|
%m = alloc() : memref<100xf32>
|
|
|
|
%c11 = constant 11 : index
|
|
|
|
%c7 = constant 7.0 : f32
|
|
|
|
store %c7, %m[%c11] : memref<100xf32>
|
2018-11-10 01:42:24 +08:00
|
|
|
// expected-note@-1 {{dependence from 0 to 0 at depth 1 = false}}
|
|
|
|
// expected-note@-2 {{dependence from 0 to 1 at depth 1 = true}}
|
2018-11-03 00:55:04 +08:00
|
|
|
%v0 = load %m[%c11] : memref<100xf32>
|
2018-11-10 01:42:24 +08:00
|
|
|
// expected-note@-1 {{dependence from 1 to 0 at depth 1 = false}}
|
|
|
|
// expected-note@-2 {{dependence from 1 to 1 at depth 1 = false}}
|
2018-11-03 00:55:04 +08:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK-LABEL: func @load_load_same_element() {
|
|
|
|
func @load_load_same_element() {
|
2018-11-03 00:55:04 +08:00
|
|
|
%m = alloc() : memref<100xf32>
|
|
|
|
%c11 = constant 11 : index
|
|
|
|
%c7 = constant 7.0 : f32
|
|
|
|
%v0 = load %m[%c11] : memref<100xf32>
|
2018-11-10 01:42:24 +08:00
|
|
|
// expected-note@-1 {{dependence from 0 to 0 at depth 1 = false}}
|
|
|
|
// expected-note@-2 {{dependence from 0 to 1 at depth 1 = false}}
|
2018-11-03 00:55:04 +08:00
|
|
|
%v1 = load %m[%c11] : memref<100xf32>
|
2018-11-10 01:42:24 +08:00
|
|
|
// expected-note@-1 {{dependence from 1 to 0 at depth 1 = false}}
|
|
|
|
// expected-note@-2 {{dependence from 1 to 1 at depth 1 = false}}
|
2018-11-03 00:55:04 +08:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK-LABEL: func @store_load_same_symbol(%arg0: index) {
|
|
|
|
func @store_load_same_symbol(%arg0: index) {
|
2018-11-03 00:55:04 +08:00
|
|
|
%m = alloc() : memref<100xf32>
|
|
|
|
%c7 = constant 7.0 : f32
|
|
|
|
store %c7, %m[%arg0] : memref<100xf32>
|
2018-11-10 01:42:24 +08:00
|
|
|
// expected-note@-1 {{dependence from 0 to 0 at depth 1 = false}}
|
|
|
|
// expected-note@-2 {{dependence from 0 to 1 at depth 1 = true}}
|
2018-11-03 00:55:04 +08:00
|
|
|
%v0 = load %m[%arg0] : memref<100xf32>
|
2018-11-10 01:42:24 +08:00
|
|
|
// expected-note@-1 {{dependence from 1 to 0 at depth 1 = false}}
|
|
|
|
// expected-note@-2 {{dependence from 1 to 1 at depth 1 = false}}
|
2018-11-03 00:55:04 +08:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK-LABEL: func @store_load_different_symbols(%arg0: index, %arg1: index) {
|
|
|
|
func @store_load_different_symbols(%arg0: index, %arg1: index) {
|
2018-11-03 00:55:04 +08:00
|
|
|
%m = alloc() : memref<100xf32>
|
|
|
|
%c7 = constant 7.0 : f32
|
|
|
|
store %c7, %m[%arg0] : memref<100xf32>
|
2018-11-10 01:42:24 +08:00
|
|
|
// expected-note@-1 {{dependence from 0 to 0 at depth 1 = false}}
|
|
|
|
// expected-note@-2 {{dependence from 0 to 1 at depth 1 = true}}
|
2018-11-03 00:55:04 +08:00
|
|
|
%v0 = load %m[%arg1] : memref<100xf32>
|
2018-11-10 01:42:24 +08:00
|
|
|
// expected-note@-1 {{dependence from 1 to 0 at depth 1 = false}}
|
|
|
|
// expected-note@-2 {{dependence from 1 to 1 at depth 1 = false}}
|
2018-11-03 00:55:04 +08:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK-LABEL: func @store_load_diff_element_affine_apply_const() {
|
|
|
|
func @store_load_diff_element_affine_apply_const() {
|
2018-11-03 00:55:04 +08:00
|
|
|
%m = alloc() : memref<100xf32>
|
|
|
|
%c1 = constant 1 : index
|
2018-12-18 12:16:37 +08:00
|
|
|
%c8 = constant 8.0 : f32
|
2019-02-07 03:08:18 +08:00
|
|
|
%a0 = affine.apply (d0) -> (d0) (%c1)
|
2018-12-18 12:16:37 +08:00
|
|
|
store %c8, %m[%a0] : memref<100xf32>
|
2018-11-10 01:42:24 +08:00
|
|
|
// expected-note@-1 {{dependence from 0 to 0 at depth 1 = false}}
|
|
|
|
// expected-note@-2 {{dependence from 0 to 1 at depth 1 = false}}
|
2019-02-07 03:08:18 +08:00
|
|
|
%a1 = affine.apply (d0) -> (d0 + 1) (%c1)
|
2018-11-03 00:55:04 +08:00
|
|
|
%v0 = load %m[%a1] : memref<100xf32>
|
2018-11-10 01:42:24 +08:00
|
|
|
// expected-note@-1 {{dependence from 1 to 0 at depth 1 = false}}
|
|
|
|
// expected-note@-2 {{dependence from 1 to 1 at depth 1 = false}}
|
2018-11-03 00:55:04 +08:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK-LABEL: func @store_load_same_element_affine_apply_const() {
|
|
|
|
func @store_load_same_element_affine_apply_const() {
|
2018-11-03 00:55:04 +08:00
|
|
|
%m = alloc() : memref<100xf32>
|
|
|
|
%c7 = constant 7.0 : f32
|
|
|
|
%c9 = constant 9 : index
|
|
|
|
%c11 = constant 11 : index
|
2019-02-07 03:08:18 +08:00
|
|
|
%a0 = affine.apply (d0) -> (d0 + 1) (%c9)
|
2018-11-03 00:55:04 +08:00
|
|
|
store %c7, %m[%a0] : memref<100xf32>
|
2018-11-10 01:42:24 +08:00
|
|
|
// expected-note@-1 {{dependence from 0 to 0 at depth 1 = false}}
|
|
|
|
// expected-note@-2 {{dependence from 0 to 1 at depth 1 = true}}
|
2019-02-07 03:08:18 +08:00
|
|
|
%a1 = affine.apply (d0) -> (d0 - 1) (%c11)
|
2018-11-03 00:55:04 +08:00
|
|
|
%v0 = load %m[%a1] : memref<100xf32>
|
2018-11-10 01:42:24 +08:00
|
|
|
// expected-note@-1 {{dependence from 1 to 0 at depth 1 = false}}
|
|
|
|
// expected-note@-2 {{dependence from 1 to 1 at depth 1 = false}}
|
2018-11-03 00:55:04 +08:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK-LABEL: func @store_load_affine_apply_symbol(%arg0: index) {
|
|
|
|
func @store_load_affine_apply_symbol(%arg0: index) {
|
2018-11-03 00:55:04 +08:00
|
|
|
%m = alloc() : memref<100xf32>
|
|
|
|
%c7 = constant 7.0 : f32
|
2019-02-07 03:08:18 +08:00
|
|
|
%a0 = affine.apply (d0) -> (d0) (%arg0)
|
2018-11-03 00:55:04 +08:00
|
|
|
store %c7, %m[%a0] : memref<100xf32>
|
2018-11-10 01:42:24 +08:00
|
|
|
// expected-note@-1 {{dependence from 0 to 0 at depth 1 = false}}
|
|
|
|
// expected-note@-2 {{dependence from 0 to 1 at depth 1 = true}}
|
2019-02-07 03:08:18 +08:00
|
|
|
%a1 = affine.apply (d0) -> (d0) (%arg0)
|
2018-11-03 00:55:04 +08:00
|
|
|
%v0 = load %m[%a1] : memref<100xf32>
|
2018-11-10 01:42:24 +08:00
|
|
|
// expected-note@-1 {{dependence from 1 to 0 at depth 1 = false}}
|
|
|
|
// expected-note@-2 {{dependence from 1 to 1 at depth 1 = false}}
|
2018-11-03 00:55:04 +08:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK-LABEL: func @store_load_affine_apply_symbol_offset(%arg0: index) {
|
|
|
|
func @store_load_affine_apply_symbol_offset(%arg0: index) {
|
2018-11-03 00:55:04 +08:00
|
|
|
%m = alloc() : memref<100xf32>
|
|
|
|
%c7 = constant 7.0 : f32
|
2019-02-07 03:08:18 +08:00
|
|
|
%a0 = affine.apply (d0) -> (d0) (%arg0)
|
2018-11-03 00:55:04 +08:00
|
|
|
store %c7, %m[%a0] : memref<100xf32>
|
2018-11-10 01:42:24 +08:00
|
|
|
// expected-note@-1 {{dependence from 0 to 0 at depth 1 = false}}
|
|
|
|
// expected-note@-2 {{dependence from 0 to 1 at depth 1 = false}}
|
2019-02-07 03:08:18 +08:00
|
|
|
%a1 = affine.apply (d0) -> (d0 + 1) (%arg0)
|
2018-11-03 00:55:04 +08:00
|
|
|
%v0 = load %m[%a1] : memref<100xf32>
|
2018-11-10 01:42:24 +08:00
|
|
|
// expected-note@-1 {{dependence from 1 to 0 at depth 1 = false}}
|
|
|
|
// expected-note@-2 {{dependence from 1 to 1 at depth 1 = false}}
|
2018-11-03 00:55:04 +08:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK-LABEL: func @store_range_load_after_range() {
|
|
|
|
func @store_range_load_after_range() {
|
2018-11-03 00:55:04 +08:00
|
|
|
%m = alloc() : memref<100xf32>
|
|
|
|
%c7 = constant 7.0 : f32
|
|
|
|
%c10 = constant 10 : index
|
2019-02-07 13:54:18 +08:00
|
|
|
for %i0 = 0 to 10 {
|
2019-02-07 03:08:18 +08:00
|
|
|
%a0 = affine.apply (d0) -> (d0) (%i0)
|
2018-11-03 00:55:04 +08:00
|
|
|
store %c7, %m[%a0] : memref<100xf32>
|
2018-11-10 01:42:24 +08:00
|
|
|
// expected-note@-1 {{dependence from 0 to 0 at depth 1 = false}}
|
|
|
|
// expected-note@-2 {{dependence from 0 to 0 at depth 2 = false}}
|
|
|
|
// expected-note@-3 {{dependence from 0 to 1 at depth 1 = false}}
|
|
|
|
// expected-note@-4 {{dependence from 0 to 1 at depth 2 = false}}
|
2019-02-07 03:08:18 +08:00
|
|
|
%a1 = affine.apply (d0) -> (d0) (%c10)
|
2018-11-03 00:55:04 +08:00
|
|
|
%v0 = load %m[%a1] : memref<100xf32>
|
2018-11-10 01:42:24 +08:00
|
|
|
// expected-note@-1 {{dependence from 1 to 0 at depth 1 = false}}
|
|
|
|
// expected-note@-2 {{dependence from 1 to 0 at depth 2 = false}}
|
|
|
|
// expected-note@-3 {{dependence from 1 to 1 at depth 1 = false}}
|
|
|
|
// expected-note@-4 {{dependence from 1 to 1 at depth 2 = false}}
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK-LABEL: func @store_load_func_symbol(%arg0: index, %arg1: index) {
|
|
|
|
func @store_load_func_symbol(%arg0: index, %arg1: index) {
|
2018-11-10 01:42:24 +08:00
|
|
|
%m = alloc() : memref<100xf32>
|
|
|
|
%c7 = constant 7.0 : f32
|
|
|
|
%c10 = constant 10 : index
|
2019-02-07 13:54:18 +08:00
|
|
|
for %i0 = 0 to %arg1 {
|
2019-02-07 03:08:18 +08:00
|
|
|
%a0 = affine.apply (d0) -> (d0) (%arg0)
|
2018-11-10 01:42:24 +08:00
|
|
|
store %c7, %m[%a0] : memref<100xf32>
|
2018-12-19 08:38:24 +08:00
|
|
|
// expected-note@-1 {{dependence from 0 to 0 at depth 1 = [1, +inf]}}
|
2018-11-10 01:42:24 +08:00
|
|
|
// expected-note@-2 {{dependence from 0 to 0 at depth 2 = false}}
|
2018-12-19 08:38:24 +08:00
|
|
|
// expected-note@-3 {{dependence from 0 to 1 at depth 1 = [1, +inf]}}
|
2018-11-10 01:42:24 +08:00
|
|
|
// expected-note@-4 {{dependence from 0 to 1 at depth 2 = true}}
|
2019-02-07 03:08:18 +08:00
|
|
|
%a1 = affine.apply (d0) -> (d0) (%arg0)
|
2018-11-10 01:42:24 +08:00
|
|
|
%v0 = load %m[%a1] : memref<100xf32>
|
2018-12-19 08:38:24 +08:00
|
|
|
// expected-note@-1 {{dependence from 1 to 0 at depth 1 = [1, +inf]}}
|
2018-11-10 01:42:24 +08:00
|
|
|
// expected-note@-2 {{dependence from 1 to 0 at depth 2 = false}}
|
|
|
|
// expected-note@-3 {{dependence from 1 to 1 at depth 1 = false}}
|
|
|
|
// expected-note@-4 {{dependence from 1 to 1 at depth 2 = false}}
|
2018-11-03 00:55:04 +08:00
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK-LABEL: func @store_range_load_last_in_range() {
|
|
|
|
func @store_range_load_last_in_range() {
|
2018-11-03 00:55:04 +08:00
|
|
|
%m = alloc() : memref<100xf32>
|
|
|
|
%c7 = constant 7.0 : f32
|
|
|
|
%c10 = constant 10 : index
|
2019-02-07 13:54:18 +08:00
|
|
|
for %i0 = 0 to 10 {
|
2019-02-07 03:08:18 +08:00
|
|
|
%a0 = affine.apply (d0) -> (d0) (%i0)
|
2018-11-10 01:42:24 +08:00
|
|
|
// For dependence from 0 to 1, we do not have a loop carried dependence
|
|
|
|
// because only the final write in the loop accesses the same element as the
|
|
|
|
// load, so this dependence appears only at depth 2 (loop independent).
|
2018-11-03 00:55:04 +08:00
|
|
|
store %c7, %m[%a0] : memref<100xf32>
|
2018-11-10 01:42:24 +08:00
|
|
|
// expected-note@-1 {{dependence from 0 to 0 at depth 1 = false}}
|
|
|
|
// expected-note@-2 {{dependence from 0 to 0 at depth 2 = false}}
|
|
|
|
// expected-note@-3 {{dependence from 0 to 1 at depth 1 = false}}
|
|
|
|
// expected-note@-4 {{dependence from 0 to 1 at depth 2 = true}}
|
2019-02-07 03:08:18 +08:00
|
|
|
%a1 = affine.apply (d0) -> (d0 - 1) (%c10)
|
2018-11-10 01:42:24 +08:00
|
|
|
// For dependence from 1 to 0, we have write-after-read (WAR) dependences
|
|
|
|
// for all loads in the loop to the store on the last iteration.
|
2018-11-03 00:55:04 +08:00
|
|
|
%v0 = load %m[%a1] : memref<100xf32>
|
2018-11-10 01:42:24 +08:00
|
|
|
// expected-note@-1 {{dependence from 1 to 0 at depth 1 = [1, 9]}}
|
|
|
|
// expected-note@-2 {{dependence from 1 to 0 at depth 2 = false}}
|
|
|
|
// expected-note@-3 {{dependence from 1 to 1 at depth 1 = false}}
|
|
|
|
// expected-note@-4 {{dependence from 1 to 1 at depth 2 = false}}
|
2018-11-03 00:55:04 +08:00
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK-LABEL: func @store_range_load_before_range() {
|
|
|
|
func @store_range_load_before_range() {
|
2018-11-03 00:55:04 +08:00
|
|
|
%m = alloc() : memref<100xf32>
|
|
|
|
%c7 = constant 7.0 : f32
|
|
|
|
%c0 = constant 0 : index
|
2019-02-07 13:54:18 +08:00
|
|
|
for %i0 = 1 to 11 {
|
2019-02-07 03:08:18 +08:00
|
|
|
%a0 = affine.apply (d0) -> (d0) (%i0)
|
2018-11-03 00:55:04 +08:00
|
|
|
store %c7, %m[%a0] : memref<100xf32>
|
2018-11-10 01:42:24 +08:00
|
|
|
// expected-note@-1 {{dependence from 0 to 0 at depth 1 = false}}
|
|
|
|
// expected-note@-2 {{dependence from 0 to 0 at depth 2 = false}}
|
|
|
|
// expected-note@-3 {{dependence from 0 to 1 at depth 1 = false}}
|
|
|
|
// expected-note@-4 {{dependence from 0 to 1 at depth 2 = false}}
|
2019-02-07 03:08:18 +08:00
|
|
|
%a1 = affine.apply (d0) -> (d0) (%c0)
|
2018-11-03 00:55:04 +08:00
|
|
|
%v0 = load %m[%a1] : memref<100xf32>
|
2018-11-10 01:42:24 +08:00
|
|
|
// expected-note@-1 {{dependence from 1 to 0 at depth 1 = false}}
|
|
|
|
// expected-note@-2 {{dependence from 1 to 0 at depth 2 = false}}
|
|
|
|
// expected-note@-3 {{dependence from 1 to 1 at depth 1 = false}}
|
|
|
|
// expected-note@-4 {{dependence from 1 to 1 at depth 2 = false}}
|
2018-11-03 00:55:04 +08:00
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK-LABEL: func @store_range_load_first_in_range() {
|
|
|
|
func @store_range_load_first_in_range() {
|
2018-11-03 00:55:04 +08:00
|
|
|
%m = alloc() : memref<100xf32>
|
|
|
|
%c7 = constant 7.0 : f32
|
|
|
|
%c0 = constant 0 : index
|
2019-02-07 13:54:18 +08:00
|
|
|
for %i0 = 1 to 11 {
|
2019-02-07 03:08:18 +08:00
|
|
|
%a0 = affine.apply (d0) -> (d0) (%i0)
|
2018-11-10 01:42:24 +08:00
|
|
|
// Dependence from 0 to 1 at depth 1 is a range because all loads at
|
|
|
|
// constant index zero are reads after first store at index zero during
|
|
|
|
// first iteration of the loop.
|
2018-11-03 00:55:04 +08:00
|
|
|
store %c7, %m[%a0] : memref<100xf32>
|
2018-11-10 01:42:24 +08:00
|
|
|
// expected-note@-1 {{dependence from 0 to 0 at depth 1 = false}}
|
|
|
|
// expected-note@-2 {{dependence from 0 to 0 at depth 2 = false}}
|
|
|
|
// expected-note@-3 {{dependence from 0 to 1 at depth 1 = [1, 9]}}
|
|
|
|
// expected-note@-4 {{dependence from 0 to 1 at depth 2 = true}}
|
2019-02-07 03:08:18 +08:00
|
|
|
%a1 = affine.apply (d0) -> (d0 + 1) (%c0)
|
2018-11-03 00:55:04 +08:00
|
|
|
%v0 = load %m[%a1] : memref<100xf32>
|
2018-11-10 01:42:24 +08:00
|
|
|
// expected-note@-1 {{dependence from 1 to 0 at depth 1 = false}}
|
|
|
|
// expected-note@-2 {{dependence from 1 to 0 at depth 2 = false}}
|
|
|
|
// expected-note@-3 {{dependence from 1 to 1 at depth 1 = false}}
|
|
|
|
// expected-note@-4 {{dependence from 1 to 1 at depth 2 = false}}
|
2018-11-03 00:55:04 +08:00
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK-LABEL: func @store_plus_3() {
|
|
|
|
func @store_plus_3() {
|
2018-11-03 00:55:04 +08:00
|
|
|
%m = alloc() : memref<100xf32>
|
|
|
|
%c7 = constant 7.0 : f32
|
2019-02-07 13:54:18 +08:00
|
|
|
for %i0 = 1 to 11 {
|
2019-02-07 03:08:18 +08:00
|
|
|
%a0 = affine.apply (d0) -> (d0 + 3) (%i0)
|
2018-11-03 00:55:04 +08:00
|
|
|
store %c7, %m[%a0] : memref<100xf32>
|
2018-11-10 01:42:24 +08:00
|
|
|
// expected-note@-1 {{dependence from 0 to 0 at depth 1 = false}}
|
|
|
|
// expected-note@-2 {{dependence from 0 to 0 at depth 2 = false}}
|
|
|
|
// expected-note@-3 {{dependence from 0 to 1 at depth 1 = [3, 3]}}
|
|
|
|
// expected-note@-4 {{dependence from 0 to 1 at depth 2 = false}}
|
2019-02-07 03:08:18 +08:00
|
|
|
%a1 = affine.apply (d0) -> (d0) (%i0)
|
2018-11-03 00:55:04 +08:00
|
|
|
%v0 = load %m[%a1] : memref<100xf32>
|
2018-11-10 01:42:24 +08:00
|
|
|
// expected-note@-1 {{dependence from 1 to 0 at depth 1 = false}}
|
|
|
|
// expected-note@-2 {{dependence from 1 to 0 at depth 2 = false}}
|
|
|
|
// expected-note@-3 {{dependence from 1 to 1 at depth 1 = false}}
|
|
|
|
// expected-note@-4 {{dependence from 1 to 1 at depth 2 = false}}
|
2018-11-03 00:55:04 +08:00
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK-LABEL: func @load_minus_2() {
|
|
|
|
func @load_minus_2() {
|
2018-11-03 00:55:04 +08:00
|
|
|
%m = alloc() : memref<100xf32>
|
|
|
|
%c7 = constant 7.0 : f32
|
2019-02-07 13:54:18 +08:00
|
|
|
for %i0 = 2 to 11 {
|
2019-02-07 03:08:18 +08:00
|
|
|
%a0 = affine.apply (d0) -> (d0) (%i0)
|
2018-11-03 00:55:04 +08:00
|
|
|
store %c7, %m[%a0] : memref<100xf32>
|
2018-11-10 01:42:24 +08:00
|
|
|
// expected-note@-1 {{dependence from 0 to 0 at depth 1 = false}}
|
|
|
|
// expected-note@-2 {{dependence from 0 to 0 at depth 2 = false}}
|
|
|
|
// expected-note@-3 {{dependence from 0 to 1 at depth 1 = [2, 2]}}
|
|
|
|
// expected-note@-4 {{dependence from 0 to 1 at depth 2 = false}}
|
2019-02-07 03:08:18 +08:00
|
|
|
%a1 = affine.apply (d0) -> (d0 - 2) (%i0)
|
2018-11-03 00:55:04 +08:00
|
|
|
%v0 = load %m[%a1] : memref<100xf32>
|
2018-11-10 01:42:24 +08:00
|
|
|
// expected-note@-1 {{dependence from 1 to 0 at depth 1 = false}}
|
|
|
|
// expected-note@-2 {{dependence from 1 to 0 at depth 2 = false}}
|
|
|
|
// expected-note@-3 {{dependence from 1 to 1 at depth 1 = false}}
|
|
|
|
// expected-note@-4 {{dependence from 1 to 1 at depth 2 = false}}
|
2018-11-03 00:55:04 +08:00
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK-LABEL: func @perfectly_nested_loops_loop_independent() {
|
|
|
|
func @perfectly_nested_loops_loop_independent() {
|
2018-11-03 00:55:04 +08:00
|
|
|
%m = alloc() : memref<10x10xf32>
|
|
|
|
%c7 = constant 7.0 : f32
|
2019-02-07 13:54:18 +08:00
|
|
|
for %i0 = 0 to 11 {
|
|
|
|
for %i1 = 0 to 11 {
|
2018-11-10 01:42:24 +08:00
|
|
|
// Dependence from access 0 to 1 is loop independent at depth = 3.
|
2019-02-07 03:08:18 +08:00
|
|
|
%a00 = affine.apply (d0, d1) -> (d0) (%i0, %i1)
|
|
|
|
%a01 = affine.apply (d0, d1) -> (d1) (%i0, %i1)
|
2019-01-26 08:36:15 +08:00
|
|
|
store %c7, %m[%a00, %a01] : memref<10x10xf32>
|
2018-11-10 01:42:24 +08:00
|
|
|
// expected-note@-1 {{dependence from 0 to 0 at depth 1 = false}}
|
|
|
|
// expected-note@-2 {{dependence from 0 to 0 at depth 2 = false}}
|
|
|
|
// expected-note@-3 {{dependence from 0 to 0 at depth 3 = false}}
|
|
|
|
// expected-note@-4 {{dependence from 0 to 1 at depth 1 = false}}
|
|
|
|
// expected-note@-5 {{dependence from 0 to 1 at depth 2 = false}}
|
|
|
|
// expected-note@-6 {{dependence from 0 to 1 at depth 3 = true}}
|
2019-02-07 03:08:18 +08:00
|
|
|
%a10 = affine.apply (d0, d1) -> (d0) (%i0, %i1)
|
|
|
|
%a11 = affine.apply (d0, d1) -> (d1) (%i0, %i1)
|
2019-01-26 08:36:15 +08:00
|
|
|
%v0 = load %m[%a10, %a11] : memref<10x10xf32>
|
2018-11-10 01:42:24 +08:00
|
|
|
// expected-note@-1 {{dependence from 1 to 0 at depth 1 = false}}
|
|
|
|
// expected-note@-2 {{dependence from 1 to 0 at depth 2 = false}}
|
|
|
|
// expected-note@-3 {{dependence from 1 to 0 at depth 3 = false}}
|
|
|
|
// expected-note@-4 {{dependence from 1 to 1 at depth 1 = false}}
|
|
|
|
// expected-note@-5 {{dependence from 1 to 1 at depth 2 = false}}
|
|
|
|
// expected-note@-6 {{dependence from 1 to 1 at depth 3 = false}}
|
2018-11-03 00:55:04 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK-LABEL: func @perfectly_nested_loops_loop_carried_at_depth1() {
|
|
|
|
func @perfectly_nested_loops_loop_carried_at_depth1() {
|
2018-11-03 00:55:04 +08:00
|
|
|
%m = alloc() : memref<10x10xf32>
|
|
|
|
%c7 = constant 7.0 : f32
|
2019-02-07 13:54:18 +08:00
|
|
|
for %i0 = 0 to 9 {
|
|
|
|
for %i1 = 0 to 9 {
|
2018-11-10 01:42:24 +08:00
|
|
|
// Dependence from access 0 to 1 is loop carried at depth 1.
|
2019-02-07 03:08:18 +08:00
|
|
|
%a00 = affine.apply (d0, d1) -> (d0) (%i0, %i1)
|
|
|
|
%a01 = affine.apply (d0, d1) -> (d1) (%i0, %i1)
|
2019-01-26 08:36:15 +08:00
|
|
|
store %c7, %m[%a00, %a01] : memref<10x10xf32>
|
2018-11-10 01:42:24 +08:00
|
|
|
// expected-note@-1 {{dependence from 0 to 0 at depth 1 = false}}
|
|
|
|
// expected-note@-2 {{dependence from 0 to 0 at depth 2 = false}}
|
|
|
|
// expected-note@-3 {{dependence from 0 to 0 at depth 3 = false}}
|
|
|
|
// expected-note@-4 {{dependence from 0 to 1 at depth 1 = [2, 2][0, 0]}}
|
|
|
|
// expected-note@-5 {{dependence from 0 to 1 at depth 2 = false}}
|
|
|
|
// expected-note@-6 {{dependence from 0 to 1 at depth 3 = false}}
|
2019-02-07 03:08:18 +08:00
|
|
|
%a10 = affine.apply (d0, d1) -> (d0 - 2) (%i0, %i1)
|
|
|
|
%a11 = affine.apply (d0, d1) -> (d1) (%i0, %i1)
|
2019-01-26 08:36:15 +08:00
|
|
|
%v0 = load %m[%a10, %a11] : memref<10x10xf32>
|
2018-11-10 01:42:24 +08:00
|
|
|
// expected-note@-1 {{dependence from 1 to 0 at depth 1 = false}}
|
|
|
|
// expected-note@-2 {{dependence from 1 to 0 at depth 2 = false}}
|
|
|
|
// expected-note@-3 {{dependence from 1 to 0 at depth 3 = false}}
|
|
|
|
// expected-note@-4 {{dependence from 1 to 1 at depth 1 = false}}
|
|
|
|
// expected-note@-5 {{dependence from 1 to 1 at depth 2 = false}}
|
|
|
|
// expected-note@-6 {{dependence from 1 to 1 at depth 3 = false}}
|
2018-11-03 00:55:04 +08:00
|
|
|
}
|
|
|
|
}
|
2018-11-10 01:42:24 +08:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK-LABEL: func @perfectly_nested_loops_loop_carried_at_depth2() {
|
|
|
|
func @perfectly_nested_loops_loop_carried_at_depth2() {
|
2018-11-10 01:42:24 +08:00
|
|
|
%m = alloc() : memref<10x10xf32>
|
|
|
|
%c7 = constant 7.0 : f32
|
2019-02-07 13:54:18 +08:00
|
|
|
for %i0 = 0 to 10 {
|
|
|
|
for %i1 = 0 to 10 {
|
2018-11-10 01:42:24 +08:00
|
|
|
// Dependence from access 0 to 1 is loop carried at depth 2.
|
2019-02-07 03:08:18 +08:00
|
|
|
%a00 = affine.apply (d0, d1) -> (d0) (%i0, %i1)
|
|
|
|
%a01 = affine.apply (d0, d1) -> (d1) (%i0, %i1)
|
2019-01-26 08:36:15 +08:00
|
|
|
store %c7, %m[%a00, %a01] : memref<10x10xf32>
|
2018-11-10 01:42:24 +08:00
|
|
|
// expected-note@-1 {{dependence from 0 to 0 at depth 1 = false}}
|
|
|
|
// expected-note@-2 {{dependence from 0 to 0 at depth 2 = false}}
|
|
|
|
// expected-note@-3 {{dependence from 0 to 0 at depth 3 = false}}
|
|
|
|
// expected-note@-4 {{dependence from 0 to 1 at depth 1 = false}}
|
|
|
|
// expected-note@-5 {{dependence from 0 to 1 at depth 2 = [0, 0][3, 3]}}
|
|
|
|
// expected-note@-6 {{dependence from 0 to 1 at depth 3 = false}}
|
2019-02-07 03:08:18 +08:00
|
|
|
%a10 = affine.apply (d0, d1) -> (d0) (%i0, %i1)
|
|
|
|
%a11 = affine.apply (d0, d1) -> (d1 - 3) (%i0, %i1)
|
2019-01-26 08:36:15 +08:00
|
|
|
%v0 = load %m[%a10, %a11] : memref<10x10xf32>
|
2018-11-10 01:42:24 +08:00
|
|
|
// expected-note@-1 {{dependence from 1 to 0 at depth 1 = false}}
|
|
|
|
// expected-note@-2 {{dependence from 1 to 0 at depth 2 = false}}
|
|
|
|
// expected-note@-3 {{dependence from 1 to 0 at depth 3 = false}}
|
|
|
|
// expected-note@-4 {{dependence from 1 to 1 at depth 1 = false}}
|
|
|
|
// expected-note@-5 {{dependence from 1 to 1 at depth 2 = false}}
|
|
|
|
// expected-note@-6 {{dependence from 1 to 1 at depth 3 = false}}
|
2018-11-03 00:55:04 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK-LABEL: func @one_common_loop() {
|
|
|
|
func @one_common_loop() {
|
2018-11-03 00:55:04 +08:00
|
|
|
%m = alloc() : memref<10x10xf32>
|
|
|
|
%c7 = constant 7.0 : f32
|
2018-11-10 01:42:24 +08:00
|
|
|
// There is a loop-independent dependence from access 0 to 1 at depth 2.
|
2019-02-07 13:54:18 +08:00
|
|
|
for %i0 = 0 to 10 {
|
|
|
|
for %i1 = 0 to 10 {
|
2019-02-07 03:08:18 +08:00
|
|
|
%a00 = affine.apply (d0, d1) -> (d0) (%i0, %i1)
|
|
|
|
%a01 = affine.apply (d0, d1) -> (d1) (%i0, %i1)
|
2019-01-26 08:36:15 +08:00
|
|
|
store %c7, %m[%a00, %a01] : memref<10x10xf32>
|
2018-11-10 01:42:24 +08:00
|
|
|
// expected-note@-1 {{dependence from 0 to 0 at depth 1 = false}}
|
|
|
|
// expected-note@-2 {{dependence from 0 to 0 at depth 2 = false}}
|
|
|
|
// expected-note@-3 {{dependence from 0 to 0 at depth 3 = false}}
|
|
|
|
// expected-note@-4 {{dependence from 0 to 1 at depth 1 = false}}
|
|
|
|
// expected-note@-5 {{dependence from 0 to 1 at depth 2 = true}}
|
2018-11-03 00:55:04 +08:00
|
|
|
}
|
2019-02-07 13:54:18 +08:00
|
|
|
for %i2 = 0 to 9 {
|
2019-02-07 03:08:18 +08:00
|
|
|
%a10 = affine.apply (d0, d1) -> (d0) (%i0, %i2)
|
|
|
|
%a11 = affine.apply (d0, d1) -> (d1) (%i0, %i2)
|
2019-01-26 08:36:15 +08:00
|
|
|
%v0 = load %m[%a10, %a11] : memref<10x10xf32>
|
2018-11-10 01:42:24 +08:00
|
|
|
// expected-note@-1 {{dependence from 1 to 0 at depth 1 = false}}
|
|
|
|
// expected-note@-2 {{dependence from 1 to 0 at depth 2 = false}}
|
|
|
|
// expected-note@-3 {{dependence from 1 to 1 at depth 1 = false}}
|
|
|
|
// expected-note@-4 {{dependence from 1 to 1 at depth 2 = false}}
|
|
|
|
// expected-note@-5 {{dependence from 1 to 1 at depth 3 = false}}
|
2018-11-03 00:55:04 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK-LABEL: func @dependence_cycle() {
|
|
|
|
func @dependence_cycle() {
|
2018-11-10 01:42:24 +08:00
|
|
|
%m.a = alloc() : memref<100xf32>
|
|
|
|
%m.b = alloc() : memref<100xf32>
|
|
|
|
|
|
|
|
// Dependences:
|
|
|
|
// *) loop-independent dependence from access 1 to 2 at depth 2.
|
|
|
|
// *) loop-carried dependence from access 3 to 0 at depth 1.
|
2019-02-07 13:54:18 +08:00
|
|
|
for %i0 = 0 to 9 {
|
2019-02-07 03:08:18 +08:00
|
|
|
%a0 = affine.apply (d0) -> (d0) (%i0)
|
2018-11-10 01:42:24 +08:00
|
|
|
%v0 = load %m.a[%a0] : memref<100xf32>
|
|
|
|
// expected-note@-1 {{dependence from 0 to 0 at depth 1 = false}}
|
|
|
|
// expected-note@-2 {{dependence from 0 to 0 at depth 2 = false}}
|
|
|
|
// expected-note@-3 {{dependence from 0 to 1 at depth 1 = false}}
|
|
|
|
// expected-note@-4 {{dependence from 0 to 1 at depth 2 = false}}
|
|
|
|
// expected-note@-5 {{dependence from 0 to 2 at depth 1 = false}}
|
|
|
|
// expected-note@-6 {{dependence from 0 to 2 at depth 2 = false}}
|
|
|
|
// expected-note@-7 {{dependence from 0 to 3 at depth 1 = false}}
|
|
|
|
// expected-note@-8 {{dependence from 0 to 3 at depth 2 = false}}
|
2019-02-07 03:08:18 +08:00
|
|
|
%a1 = affine.apply (d0) -> (d0) (%i0)
|
2018-11-10 01:42:24 +08:00
|
|
|
store %v0, %m.b[%a1] : memref<100xf32>
|
|
|
|
// expected-note@-1 {{dependence from 1 to 0 at depth 1 = false}}
|
|
|
|
// expected-note@-2 {{dependence from 1 to 0 at depth 2 = false}}
|
|
|
|
// expected-note@-3 {{dependence from 1 to 1 at depth 1 = false}}
|
|
|
|
// expected-note@-4 {{dependence from 1 to 1 at depth 2 = false}}
|
|
|
|
// expected-note@-5 {{dependence from 1 to 2 at depth 1 = false}}
|
|
|
|
// expected-note@-6 {{dependence from 1 to 2 at depth 2 = true}}
|
|
|
|
// expected-note@-7 {{dependence from 1 to 3 at depth 1 = false}}
|
|
|
|
// expected-note@-8 {{dependence from 1 to 3 at depth 2 = false}}
|
2019-02-07 03:08:18 +08:00
|
|
|
%a2 = affine.apply (d0) -> (d0) (%i0)
|
2018-11-10 01:42:24 +08:00
|
|
|
%v1 = load %m.b[%a2] : memref<100xf32>
|
|
|
|
// expected-note@-1 {{dependence from 2 to 0 at depth 1 = false}}
|
|
|
|
// expected-note@-2 {{dependence from 2 to 0 at depth 2 = false}}
|
|
|
|
// expected-note@-3 {{dependence from 2 to 1 at depth 1 = false}}
|
|
|
|
// expected-note@-4 {{dependence from 2 to 1 at depth 2 = false}}
|
|
|
|
// expected-note@-5 {{dependence from 2 to 2 at depth 1 = false}}
|
|
|
|
// expected-note@-6 {{dependence from 2 to 2 at depth 2 = false}}
|
|
|
|
// expected-note@-7 {{dependence from 2 to 3 at depth 1 = false}}
|
|
|
|
// expected-note@-8 {{dependence from 2 to 3 at depth 2 = false}}
|
2019-02-07 03:08:18 +08:00
|
|
|
%a3 = affine.apply (d0) -> (d0 + 1) (%i0)
|
2018-11-10 01:42:24 +08:00
|
|
|
store %v1, %m.a[%a3] : memref<100xf32>
|
|
|
|
// expected-note@-1 {{dependence from 3 to 0 at depth 1 = [1, 1]}}
|
|
|
|
// expected-note@-2 {{dependence from 3 to 0 at depth 2 = false}}
|
|
|
|
// expected-note@-3 {{dependence from 3 to 1 at depth 1 = false}}
|
|
|
|
// expected-note@-4 {{dependence from 3 to 1 at depth 2 = false}}
|
|
|
|
// expected-note@-5 {{dependence from 3 to 2 at depth 1 = false}}
|
|
|
|
// expected-note@-6 {{dependence from 3 to 2 at depth 2 = false}}
|
|
|
|
// expected-note@-7 {{dependence from 3 to 3 at depth 1 = false}}
|
|
|
|
// expected-note@-8 {{dependence from 3 to 3 at depth 2 = false}}
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK-LABEL: func @negative_and_positive_direction_vectors(%arg0: index, %arg1: index) {
|
|
|
|
func @negative_and_positive_direction_vectors(%arg0: index, %arg1: index) {
|
2018-11-03 00:55:04 +08:00
|
|
|
%m = alloc() : memref<10x10xf32>
|
|
|
|
%c7 = constant 7.0 : f32
|
2019-02-07 13:54:18 +08:00
|
|
|
for %i0 = 0 to %arg0 {
|
|
|
|
for %i1 = 0 to %arg1 {
|
2019-02-07 03:08:18 +08:00
|
|
|
%a00 = affine.apply (d0, d1) -> (d0 - 1) (%i0, %i1)
|
|
|
|
%a01 = affine.apply (d0, d1) -> (d1 + 1) (%i0, %i1)
|
2019-01-26 08:36:15 +08:00
|
|
|
%v0 = load %m[%a00, %a01] : memref<10x10xf32>
|
2018-11-10 01:42:24 +08:00
|
|
|
// expected-note@-1 {{dependence from 0 to 0 at depth 1 = false}}
|
|
|
|
// expected-note@-2 {{dependence from 0 to 0 at depth 2 = false}}
|
|
|
|
// expected-note@-3 {{dependence from 0 to 0 at depth 3 = false}}
|
|
|
|
// expected-note@-4 {{dependence from 0 to 1 at depth 1 = false}}
|
|
|
|
// expected-note@-5 {{dependence from 0 to 1 at depth 2 = false}}
|
|
|
|
// expected-note@-6 {{dependence from 0 to 1 at depth 3 = false}}
|
2019-02-07 03:08:18 +08:00
|
|
|
%a10 = affine.apply (d0, d1) -> (d0) (%i0, %i1)
|
|
|
|
%a11 = affine.apply (d0, d1) -> (d1) (%i0, %i1)
|
2019-01-26 08:36:15 +08:00
|
|
|
store %c7, %m[%a10, %a11] : memref<10x10xf32>
|
2018-11-10 01:42:24 +08:00
|
|
|
// expected-note@-1 {{dependence from 1 to 0 at depth 1 = [1, 1][-1, -1]}}
|
|
|
|
// expected-note@-2 {{dependence from 1 to 0 at depth 2 = false}}
|
|
|
|
// expected-note@-3 {{dependence from 1 to 0 at depth 3 = false}}
|
|
|
|
// expected-note@-4 {{dependence from 1 to 1 at depth 1 = false}}
|
|
|
|
// expected-note@-5 {{dependence from 1 to 1 at depth 2 = false}}
|
|
|
|
// expected-note@-6 {{dependence from 1 to 1 at depth 3 = false}}
|
2018-11-03 00:55:04 +08:00
|
|
|
}
|
|
|
|
}
|
2018-11-10 01:42:24 +08:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK-LABEL: func @war_raw_waw_deps() {
|
|
|
|
func @war_raw_waw_deps() {
|
2018-11-10 01:42:24 +08:00
|
|
|
%m = alloc() : memref<100xf32>
|
|
|
|
%c7 = constant 7.0 : f32
|
2019-02-07 13:54:18 +08:00
|
|
|
for %i0 = 0 to 10 {
|
|
|
|
for %i1 = 0 to 10 {
|
2019-02-07 03:08:18 +08:00
|
|
|
%a0 = affine.apply (d0) -> (d0 + 1) (%i1)
|
2018-11-10 01:42:24 +08:00
|
|
|
%v0 = load %m[%a0] : memref<100xf32>
|
|
|
|
// expected-note@-1 {{dependence from 0 to 0 at depth 1 = false}}
|
|
|
|
// expected-note@-2 {{dependence from 0 to 0 at depth 2 = false}}
|
|
|
|
// expected-note@-3 {{dependence from 0 to 0 at depth 3 = false}}
|
|
|
|
// expected-note@-4 {{dependence from 0 to 1 at depth 1 = [1, 9][1, 1]}}
|
|
|
|
// expected-note@-5 {{dependence from 0 to 1 at depth 2 = [0, 0][1, 1]}}
|
|
|
|
// expected-note@-6 {{dependence from 0 to 1 at depth 3 = false}}
|
2019-02-07 03:08:18 +08:00
|
|
|
%a1 = affine.apply (d0) -> (d0) (%i1)
|
2018-11-10 01:42:24 +08:00
|
|
|
store %c7, %m[%a1] : memref<100xf32>
|
|
|
|
// expected-note@-1 {{dependence from 1 to 0 at depth 1 = [1, 9][-1, -1]}}
|
|
|
|
// expected-note@-2 {{dependence from 1 to 0 at depth 2 = false}}
|
|
|
|
// expected-note@-3 {{dependence from 1 to 0 at depth 3 = false}}
|
|
|
|
// expected-note@-4 {{dependence from 1 to 1 at depth 1 = [1, 9][0, 0]}}
|
|
|
|
// expected-note@-5 {{dependence from 1 to 1 at depth 2 = false}}
|
|
|
|
// expected-note@-6 {{dependence from 1 to 1 at depth 3 = false}}
|
2018-11-03 00:55:04 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
2018-12-18 12:16:37 +08:00
|
|
|
|
|
|
|
// -----
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK-LABEL: func @mod_deps() {
|
|
|
|
func @mod_deps() {
|
2018-12-18 12:16:37 +08:00
|
|
|
%m = alloc() : memref<100xf32>
|
|
|
|
%c7 = constant 7.0 : f32
|
2019-02-07 13:54:18 +08:00
|
|
|
for %i0 = 0 to 10 {
|
2019-02-07 03:08:18 +08:00
|
|
|
%a0 = affine.apply (d0) -> (d0 mod 2) (%i0)
|
2018-12-29 07:34:07 +08:00
|
|
|
// Results are conservative here since we currently don't have a way to
|
|
|
|
// represent strided sets in FlatAffineConstraints.
|
2018-12-18 12:16:37 +08:00
|
|
|
%v0 = load %m[%a0] : memref<100xf32>
|
|
|
|
// expected-note@-1 {{dependence from 0 to 0 at depth 1 = false}}
|
|
|
|
// expected-note@-2 {{dependence from 0 to 0 at depth 2 = false}}
|
|
|
|
// expected-note@-3 {{dependence from 0 to 1 at depth 1 = [1, 9]}}
|
|
|
|
// expected-note@-4 {{dependence from 0 to 1 at depth 2 = false}}
|
2019-02-07 03:08:18 +08:00
|
|
|
%a1 = affine.apply (d0) -> ( (d0 + 1) mod 2) (%i0)
|
2018-12-18 12:16:37 +08:00
|
|
|
store %c7, %m[%a1] : memref<100xf32>
|
|
|
|
// expected-note@-1 {{dependence from 1 to 0 at depth 1 = [1, 9]}}
|
|
|
|
// expected-note@-2 {{dependence from 1 to 0 at depth 2 = false}}
|
|
|
|
// expected-note@-3 {{dependence from 1 to 1 at depth 1 = [2, 9]}}
|
|
|
|
// expected-note@-4 {{dependence from 1 to 1 at depth 2 = false}}
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
2018-12-21 07:01:22 +08:00
|
|
|
|
|
|
|
// -----
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK-LABEL: func @loop_nest_depth() {
|
|
|
|
func @loop_nest_depth() {
|
2018-12-21 07:01:22 +08:00
|
|
|
%0 = alloc() : memref<100x100xf32>
|
|
|
|
%c7 = constant 7.0 : f32
|
|
|
|
|
2019-02-07 13:54:18 +08:00
|
|
|
for %i0 = 0 to 128 {
|
|
|
|
for %i1 = 0 to 8 {
|
2018-12-21 07:01:22 +08:00
|
|
|
store %c7, %0[%i0, %i1] : memref<100x100xf32>
|
|
|
|
// expected-note@-1 {{dependence from 0 to 0 at depth 1 = false}}
|
|
|
|
// expected-note@-2 {{dependence from 0 to 0 at depth 2 = false}}
|
|
|
|
// expected-note@-3 {{dependence from 0 to 0 at depth 3 = false}}
|
|
|
|
// expected-note@-4 {{dependence from 0 to 1 at depth 1 = true}}
|
|
|
|
}
|
|
|
|
}
|
2019-02-07 13:54:18 +08:00
|
|
|
for %i2 = 0 to 8 {
|
|
|
|
for %i3 = 0 to 8 {
|
|
|
|
for %i4 = 0 to 8 {
|
|
|
|
for %i5 = 0 to 16 {
|
2019-02-07 03:08:18 +08:00
|
|
|
%8 = affine.apply (d0, d1) -> (d0 * 16 + d1)(%i4, %i5)
|
2018-12-21 07:01:22 +08:00
|
|
|
%9 = load %0[%8, %i3] : memref<100x100xf32>
|
|
|
|
// expected-note@-1 {{dependence from 1 to 0 at depth 1 = false}}
|
|
|
|
// expected-note@-2 {{dependence from 1 to 1 at depth 1 = false}}
|
|
|
|
// expected-note@-3 {{dependence from 1 to 1 at depth 2 = false}}
|
|
|
|
// expected-note@-4 {{dependence from 1 to 1 at depth 3 = false}}
|
|
|
|
// expected-note@-5 {{dependence from 1 to 1 at depth 4 = false}}
|
|
|
|
// expected-note@-6 {{dependence from 1 to 1 at depth 5 = false}}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
2018-12-28 07:08:24 +08:00
|
|
|
|
|
|
|
// -----
|
|
|
|
// Test case to exercise sanity when flattening multiple expressions involving
|
|
|
|
// mod/div's successively.
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK-LABEL: func @mod_div_3d() {
|
|
|
|
func @mod_div_3d() {
|
2018-12-28 07:08:24 +08:00
|
|
|
%M = alloc() : memref<2x2x2xi32>
|
|
|
|
%c0 = constant 0 : i32
|
2019-02-07 13:54:18 +08:00
|
|
|
for %i0 = 0 to 8 {
|
|
|
|
for %i1 = 0 to 8 {
|
|
|
|
for %i2 = 0 to 8 {
|
2019-02-07 03:08:18 +08:00
|
|
|
%idx0 = affine.apply (d0, d1, d2) -> (d0 floordiv 4) (%i0, %i1, %i2)
|
|
|
|
%idx1 = affine.apply (d0, d1, d2) -> (d1 mod 2) (%i0, %i1, %i2)
|
|
|
|
%idx2 = affine.apply (d0, d1, d2) -> (d2 floordiv 4) (%i0, %i1, %i2)
|
2019-01-26 08:36:15 +08:00
|
|
|
store %c0, %M[%idx0, %idx1, %idx2] : memref<2 x 2 x 2 x i32>
|
2018-12-29 07:34:07 +08:00
|
|
|
// expected-note@-1 {{dependence from 0 to 0 at depth 1 = [1, 3][-7, 7][-3, 3]}}
|
|
|
|
// expected-note@-2 {{dependence from 0 to 0 at depth 2 = [0, 0][2, 7][-3, 3]}}
|
|
|
|
// expected-note@-3 {{dependence from 0 to 0 at depth 3 = [0, 0][0, 0][1, 3]}}
|
2018-12-28 07:08:24 +08:00
|
|
|
// expected-note@-4 {{dependence from 0 to 0 at depth 4 = false}}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
2018-12-29 07:34:07 +08:00
|
|
|
|
2018-12-30 07:51:30 +08:00
|
|
|
// -----
|
|
|
|
// This test case arises in the context of a 6-d to 2-d reshape.
|
2019-01-03 02:20:00 +08:00
|
|
|
// CHECK-LABEL: func @delinearize_mod_floordiv
|
|
|
|
func @delinearize_mod_floordiv() {
|
2018-12-30 07:51:30 +08:00
|
|
|
%c0 = constant 0 : index
|
|
|
|
%val = constant 0 : i32
|
|
|
|
%in = alloc() : memref<2x2x3x3x16x1xi32>
|
|
|
|
%out = alloc() : memref<64x9xi32>
|
|
|
|
|
2019-02-07 13:54:18 +08:00
|
|
|
for %i0 = 0 to 2 {
|
|
|
|
for %i1 = 0 to 2 {
|
|
|
|
for %i2 = 0 to 3 {
|
|
|
|
for %i3 = 0 to 3 {
|
|
|
|
for %i4 = 0 to 16 {
|
|
|
|
for %i5 = 0 to 1 {
|
2018-12-30 07:51:30 +08:00
|
|
|
store %val, %in[%i0, %i1, %i2, %i3, %i4, %i5] : memref<2x2x3x3x16x1xi32>
|
|
|
|
// expected-note@-1 {{dependence from 0 to 0 at depth 1 = false}}
|
|
|
|
// expected-note@-2 {{dependence from 0 to 0 at depth 2 = false}}
|
|
|
|
// expected-note@-3 {{dependence from 0 to 0 at depth 3 = false}}
|
|
|
|
// expected-note@-4 {{dependence from 0 to 0 at depth 4 = false}}
|
|
|
|
// expected-note@-5 {{dependence from 0 to 0 at depth 5 = false}}
|
|
|
|
// expected-note@-6 {{dependence from 0 to 0 at depth 6 = false}}
|
|
|
|
// expected-note@-7 {{dependence from 0 to 0 at depth 7 = false}}
|
|
|
|
// expected-note@-8 {{dependence from 0 to 1 at depth 1 = true}}
|
|
|
|
// expected-note@-9 {{dependence from 0 to 2 at depth 1 = false}}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-07 13:54:18 +08:00
|
|
|
for %ii = 0 to 64 {
|
|
|
|
for %jj = 0 to 9 {
|
2019-02-07 03:08:18 +08:00
|
|
|
%a0 = affine.apply (d0, d1) -> (d0 * (9 * 1024) + d1 * 128) (%ii, %jj)
|
|
|
|
%a10 = affine.apply (d0) ->
|
2019-01-26 08:36:15 +08:00
|
|
|
(d0 floordiv (2 * 3 * 3 * 128 * 128)) (%a0)
|
2019-02-07 03:08:18 +08:00
|
|
|
%a11 = affine.apply (d0) ->
|
2019-01-26 08:36:15 +08:00
|
|
|
((d0 mod 294912) floordiv (3 * 3 * 128 * 128)) (%a0)
|
2019-02-07 03:08:18 +08:00
|
|
|
%a12 = affine.apply (d0) ->
|
2019-01-26 08:36:15 +08:00
|
|
|
((((d0 mod 294912) mod 147456) floordiv 1152) floordiv 8) (%a0)
|
2019-02-07 03:08:18 +08:00
|
|
|
%a13 = affine.apply (d0) ->
|
2019-01-26 08:36:15 +08:00
|
|
|
((((d0 mod 294912) mod 147456) mod 1152) floordiv 384) (%a0)
|
2019-02-07 03:08:18 +08:00
|
|
|
%a14 = affine.apply (d0) ->
|
2019-01-26 08:36:15 +08:00
|
|
|
(((((d0 mod 294912) mod 147456) mod 1152) mod 384) floordiv 128) (%a0)
|
2019-02-07 03:08:18 +08:00
|
|
|
%a15 = affine.apply (d0) ->
|
2019-01-26 08:36:15 +08:00
|
|
|
((((((d0 mod 294912) mod 147456) mod 1152) mod 384) mod 128)
|
2018-12-30 07:51:30 +08:00
|
|
|
floordiv 128) (%a0)
|
2019-01-26 08:36:15 +08:00
|
|
|
%v0 = load %in[%a10, %a11, %a13, %a14, %a12, %a15] : memref<2x2x3x3x16x1xi32>
|
2018-12-30 07:51:30 +08:00
|
|
|
// expected-note@-1 {{dependence from 1 to 0 at depth 1 = false}}
|
|
|
|
// expected-note@-2 {{dependence from 1 to 1 at depth 1 = false}}
|
|
|
|
// expected-note@-3 {{dependence from 1 to 1 at depth 2 = false}}
|
|
|
|
// expected-note@-4 {{dependence from 1 to 1 at depth 3 = false}}
|
|
|
|
// expected-note@-5 {{dependence from 1 to 2 at depth 1 = false}}
|
|
|
|
// expected-note@-6 {{dependence from 1 to 2 at depth 2 = false}}
|
|
|
|
// expected-note@-7 {{dependence from 1 to 2 at depth 3 = false}}
|
|
|
|
// TODO(andydavis): the dep tester shouldn't be printing out these messages
|
|
|
|
// below; they are redundant.
|
|
|
|
store %v0, %out[%ii, %jj] : memref<64x9xi32>
|
|
|
|
// expected-note@-1 {{dependence from 2 to 0 at depth 1 = false}}
|
|
|
|
// expected-note@-2 {{dependence from 2 to 1 at depth 1 = false}}
|
|
|
|
// expected-note@-3 {{dependence from 2 to 1 at depth 2 = false}}
|
|
|
|
// expected-note@-4 {{dependence from 2 to 1 at depth 3 = false}}
|
|
|
|
// expected-note@-5 {{dependence from 2 to 2 at depth 1 = false}}
|
|
|
|
// expected-note@-6 {{dependence from 2 to 2 at depth 2 = false}}
|
|
|
|
// expected-note@-7 {{dependence from 2 to 2 at depth 3 = false}}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO(bondhugula): add more test cases involving mod's/div's.
|