1// RUN: mlir-opt %s -split-input-file -affine-loop-tile="tile-size=32" -verify-diagnostics | FileCheck %s 2 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 @legal_loop() 11func.func @legal_loop() { 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 : f32 17 affine.store %2, %0[%i] : memref<64xf32> 18 } 19 20 return 21} 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 affine.for %i = 0 to 64 { 37 // expected-remark@above {{tiling code is illegal due to dependences}} 38 affine.for %j = 0 to 64 { 39 %0 = affine.load %A[%j, %i] : memref<64x64xf32> 40 %1 = affine.load %A[%i, %j - 1] : memref<64x64xf32> 41 %2 = arith.addf %0, %1 : f32 42 affine.store %2, %A[%i, %j] : memref<64x64xf32> 43 } 44 } 45 46 return 47} 48