|
4 | 4 | // RUN: mlir-opt -allow-unregistered-dialect %s -test-loop-permutation="permutation-map=0,2,1" | FileCheck %s --check-prefix=CHECK-021
|
5 | 5 | // RUN: mlir-opt -allow-unregistered-dialect %s -test-loop-permutation="permutation-map=2,0,1" | FileCheck %s --check-prefix=CHECK-201
|
6 | 6 | // RUN: mlir-opt -allow-unregistered-dialect %s -test-loop-permutation="permutation-map=2,1,0" | FileCheck %s --check-prefix=CHECK-210
|
| 7 | +// RUN: mlir-opt -allow-unregistered-dialect %s -test-loop-permutation="permutation-map=2,1,0 check-validity=1" | FileCheck %s --check-prefix=CHECK-210-VALID |
7 | 8 |
|
8 | 9 | // CHECK-120-LABEL: func @permute
|
9 | 10 | func.func @permute(%U0 : index, %U1 : index, %U2 : index) {
|
@@ -45,3 +46,34 @@ func.func @permute(%U0 : index, %U1 : index, %U2 : index) {
|
45 | 46 |
|
46 | 47 | // CHECK-201: "foo"(%arg5, %arg3)
|
47 | 48 | // CHECK-201-NEXT: "bar"(%arg4)
|
| 49 | + |
| 50 | +// ----- |
| 51 | + |
| 52 | +// Tests that the permutation validation check utility conservatively returns false when the |
| 53 | +// for loop has an iter_arg. |
| 54 | + |
| 55 | +// CHECK-210-VALID-LABEL: func @check_validity_with_iter_args |
| 56 | +// CHECK-210-VALID-SAME: %[[ARG0:.*]]: index, %[[ARG1:.*]]: index, %[[ARG2:.*]]: index |
| 57 | +func.func @check_validity_with_iter_args(%U0 : index, %U1 : index, %U2 : index) { |
| 58 | + %buf = memref.alloc() : memref<100x100xf32> |
| 59 | + %cst = arith.constant 1.0 : f32 |
| 60 | + %c10 = arith.constant 10 : index |
| 61 | + %c20 = arith.constant 20 : index |
| 62 | + |
| 63 | + // Check that the loops are not permuted. |
| 64 | + // CHECK-210-VALID: affine.for %{{.*}} = 0 to %[[ARG0]] { |
| 65 | + // CHECK-210-VALID-NEXT: affine.for %{{.*}} = 0 to %[[ARG1]] { |
| 66 | + // CHECK-210-VALID-NEXT: affine.for %{{.*}} = 0 to %[[ARG2]] iter_args( |
| 67 | + affine.for %arg0 = 0 to %U0 { |
| 68 | + affine.for %arg1 = 0 to %U1 { |
| 69 | + %res = affine.for %arg2 = 0 to %U2 iter_args(%iter1 = %cst) -> (f32) { |
| 70 | + %val = affine.load %buf[%arg0 + 10, %arg1 + 20] : memref<100x100xf32> |
| 71 | + %newVal = arith.addf %val, %cst : f32 |
| 72 | + affine.store %newVal, %buf[%arg0 + 10, %arg1 + 20] : memref<100x100xf32> |
| 73 | + %newVal2 = arith.addf %newVal, %iter1 : f32 |
| 74 | + affine.yield %iter1 : f32 |
| 75 | + } |
| 76 | + } |
| 77 | + } |
| 78 | + return |
| 79 | +} |
0 commit comments