1// RUN: mlir-opt %s -for-loop-specialization -split-input-file | FileCheck %s 2 3#map0 = affine_map<()[s0, s1] -> (1024, s0 - s1)> 4#map1 = affine_map<()[s0, s1] -> (64, s0 - s1)> 5 6func @for(%outer: index, %A: memref<?xf32>, %B: memref<?xf32>, 7 %C: memref<?xf32>, %result: memref<?xf32>) { 8 %c0 = constant 0 : index 9 %c1 = constant 1 : index 10 %d0 = dim %A, %c0 : memref<?xf32> 11 %b0 = affine.min #map0()[%d0, %outer] 12 scf.for %i0 = %c0 to %b0 step %c1 { 13 %B_elem = load %B[%i0] : memref<?xf32> 14 %C_elem = load %C[%i0] : memref<?xf32> 15 %sum_elem = addf %B_elem, %C_elem : f32 16 store %sum_elem, %result[%i0] : memref<?xf32> 17 } 18 return 19} 20 21// CHECK-LABEL: func @for( 22// CHECK-SAME: [[ARG0:%.*]]: index, [[ARG1:%.*]]: memref<?xf32>, [[ARG2:%.*]]: memref<?xf32>, [[ARG3:%.*]]: memref<?xf32>, [[ARG4:%.*]]: memref<?xf32>) { 23// CHECK: [[CST_0:%.*]] = constant 0 : index 24// CHECK: [[CST_1:%.*]] = constant 1 : index 25// CHECK: [[DIM_0:%.*]] = dim [[ARG1]], [[CST_0]] : memref<?xf32> 26// CHECK: [[MIN:%.*]] = affine.min #map(){{\[}}[[DIM_0]], [[ARG0]]] 27// CHECK: [[CST_1024:%.*]] = constant 1024 : index 28// CHECK: [[PRED:%.*]] = cmpi "eq", [[MIN]], [[CST_1024]] : index 29// CHECK: scf.if [[PRED]] { 30// CHECK: scf.for [[IDX0:%.*]] = [[CST_0]] to [[CST_1024]] step [[CST_1]] { 31// CHECK: store 32// CHECK: } 33// CHECK: } else { 34// CHECK: scf.for [[IDX0:%.*]] = [[CST_0]] to [[MIN]] step [[CST_1]] { 35// CHECK: store 36// CHECK: } 37// CHECK: } 38// CHECK: return 39// CHECK: } 40