Bug fix for getConstantBoundOnDimSize

- this was detected when memref-bound-check was run on the output of the
  loop-fusion pass
- the addition (to represent ceildiv as a floordiv) had to be performed only
  for the constant term of the constraint
- update test cases
- memref-bound-check no longer returns an error on the output of this test case

PiperOrigin-RevId: 236731137
This commit is contained in:
Uday Bondhugula 2019-03-04 14:58:59 -08:00 committed by jpienaar
parent a60ba7d908
commit 12b9dece8d
2 changed files with 7 additions and 7 deletions

View File

@ -2056,11 +2056,11 @@ Optional<int64_t> FlatAffineConstraints::getConstantBoundOnDimSize(
// 31 >= 0, the lower bound for d0 is ceil(N - 31, 32), i.e., floor(N, 32).
*lbFloorDivisor = atIneq(minLbPosition, pos);
for (unsigned c = 0, e = getNumSymbolIds() + 1; c < e; c++) {
// ceildiv (val / d) = floordiv (val + d - 1 / d); hence, the addition of
// 'atIneq(minLbPosition, pos) - 1'.
(*lb)[c] = -atIneq(minLbPosition, getNumDimIds() + c) +
atIneq(minLbPosition, pos) - 1;
(*lb)[c] = -atIneq(minLbPosition, getNumDimIds() + c);
}
// ceildiv (val / d) = floordiv (val + d - 1 / d); hence, the addition of
// 'atIneq(minLbPosition, pos) - 1' to the constant term.
(*lb)[getNumSymbolIds()] += atIneq(minLbPosition, pos) - 1;
}
return minDiff;
}

View File

@ -697,7 +697,7 @@ func @R6_to_R2_reshape_square() -> memref<64x9xi32> {
// CHECK-DAG: [[MAP2:#map[0-9]+]] = (d0, d1) -> ((((d0 * 9 + d1) mod 288) mod 144) floordiv 48)
// CHECK-DAG: [[MAP3:#map[0-9]+]] = (d0, d1) -> (((((d0 * 9 + d1) mod 288) mod 144) mod 48) floordiv 16)
// CHECK-DAG: [[MAP4:#map[0-9]+]] = (d0, d1) -> (((((d0 * 9 + d1) mod 288) mod 144) mod 48) mod 16)
// CHECK-DAG: [[MAP5:#map[0-9]+]] = (d0, d1, d2, d3, d4, d5, d6, d7) -> (d2 - (d0 * 37 + d1 * 36) floordiv 36)
// CHECK-DAG: [[MAP5:#map[0-9]+]] = (d0, d1, d2, d3, d4, d5, d6, d7) -> (d2 - (d0 * 9 + d1) floordiv 288)
// CHECK-DAG: [[MAP6:#map[0-9]+]] = (d0, d1, d2, d3, d4, d5, d6, d7) -> (d3)
// CHECK-DAG: [[MAP7:#map[0-9]+]] = (d0, d1, d2, d3, d4, d5, d6, d7) -> (d4)
// CHECK-DAG: [[MAP8:#map[0-9]+]] = (d0, d1, d2, d3, d4, d5, d6, d7) -> (d5)
@ -1321,7 +1321,7 @@ func @R3_to_R2_reshape() {
return
}
// CHECK: [[MAP0:#map[0-9]+]] = (d0, d1) -> ((d0 * 3 + d1) floordiv 48)
// CHECK-NEXT: [[MAP2:#map[0-9]+]] = (d0, d1, d2, d3, d4) -> (d2 - (d0 * 25 + d1 * 24) floordiv 24)
// CHECK-NEXT: [[MAP2:#map[0-9]+]] = (d0, d1, d2, d3, d4) -> (d2 - (d0 * 3 + d1) floordiv 48)
// CHECK-NEXT: [[MAP3:#map[0-9]+]] = (d0, d1, d2, d3, d4) -> (-d1 + d3)
// CHECK-NEXT: [[MAP4:#map[0-9]+]] = (d0, d1, d2, d3, d4) -> (d4)
// CHECK-NEXT: [[MAP5:#map[0-9]+]] = (d0, d1) -> (d0 * 3 + d1)
@ -2061,4 +2061,4 @@ func @two_matrix_vector_products() {
// CHECK-NEXT: }
// CHECK-NEXT: return
return
}
}