50 lines · plain
1// RUN: mlir-opt %s -split-input-file -affine-loop-tile="tile-size=32" -verify-diagnostics | FileCheck %s2 3// -----4 5// There is no dependence violated in this case. No error should be raised.6 7// CHECK-DAG: [[$LB:#map[0-9]*]] = affine_map<(d0) -> (d0)>8// CHECK-DAG: [[$UB:#map[0-9]*]] = affine_map<(d0) -> (d0 + 32)>9 10// CHECK-LABEL: func @valid_to_tile()11func.func @valid_to_tile() {12 %0 = memref.alloc() : memref<64xf32>13 14 affine.for %i = 0 to 64 {15 %1 = affine.load %0[%i] : memref<64xf32>16 %2 = arith.addf %1, %1 : f3217 affine.store %2, %0[%i] : memref<64xf32>18 }19 20 return21}22 23// CHECK: affine.for %{{.*}} = 0 to 64 step 32 {24// CHECK-NEXT: affine.for %{{.*}} = [[$LB]](%{{.*}}) to [[$UB]](%{{.*}}) {25 26// -----27 28// There are dependences along the diagonal of the 2d iteration space,29// specifically, they are of direction (+, -).30// The default tiling method (hyper-rect) will violate tiling legality.31// We expect a remark that points that issue out to be emitted.32 33func.func @illegal_loop_with_diag_dependence() {34 %A = memref.alloc() : memref<64x64xf32>35 36 // No tiling here.37 // CHECK: affine.for %{{.*}} = 0 to 64 {38 // CHECK-NEXT: affine.for %{{.*}} = 0 to 64 {39 affine.for %i = 0 to 64 {40 affine.for %j = 0 to 64 {41 %0 = affine.load %A[%j, %i] : memref<64x64xf32>42 %1 = affine.load %A[%i, %j - 1] : memref<64x64xf32>43 %2 = arith.addf %0, %1 : f3244 affine.store %2, %A[%i, %j] : memref<64x64xf32>45 }46 }47 48 return49}50