Skip to content

Commit 28a7dfa

Browse files
kumasentobondhugula
authored andcommitted
[MLIR] Fixed missing constraint append when adding an AffineIfOp domain
The prior diff that introduced `addAffineIfOpDomain` missed appending constraints from the ifOp domain. This revision fixes this problem. Differential Revision: https://reviews.llvm.org/D86421
1 parent 5e63083 commit 28a7dfa

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

mlir/lib/Analysis/AffineStructures.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -731,8 +731,11 @@ void FlatAffineConstraints::addAffineIfOpDomain(AffineIfOp ifOp) {
731731
SmallVector<Value, 4> operands = ifOp.getOperands();
732732
cst.setIdValues(0, cst.getNumDimAndSymbolIds(), operands);
733733

734-
// Merge the constraints from ifOp to the current domain.
734+
// Merge the constraints from ifOp to the current domain. We need first merge
735+
// and align the IDs from both constraints, and then append the constraints
736+
// from the ifOp into the current one.
735737
mergeAndAlignIdsWithOther(0, &cst);
738+
append(cst);
736739
}
737740

738741
// Searches for a constraint with a non-zero coefficient at 'colIdx' in

mlir/test/Transforms/memref-dependence-check.mlir

+5-5
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ func @store_may_execute_before_load() {
99
%m = alloc() : memref<10xf32>
1010
%cf7 = constant 7.0 : f32
1111
%c0 = constant 4 : index
12-
// There is a dependence from store 0 to load 1 at depth 1 because the
13-
// ancestor IfOp of the store, dominates the ancestor ForSmt of the load,
14-
// and thus the store "may" conditionally execute before the load.
12+
// There is no dependence from store 0 to load 1 at depth if we take into account
13+
// the constraint introduced by the following `affine.if`, which indicates that
14+
// the store 0 will never be executed.
1515
affine.if #set0(%c0) {
1616
affine.for %i0 = 0 to 10 {
1717
affine.store %cf7, %m[%i0] : memref<10xf32>
1818
// expected-remark@above {{dependence from 0 to 0 at depth 1 = false}}
1919
// expected-remark@above {{dependence from 0 to 0 at depth 2 = false}}
20-
// expected-remark@above {{dependence from 0 to 1 at depth 1 = true}}
20+
// expected-remark@above {{dependence from 0 to 1 at depth 1 = false}}
2121
}
2222
}
2323
affine.for %i1 = 0 to 10 {
@@ -1044,7 +1044,7 @@ func @test_interleaved_affine_for_if() {
10441044
%N = dim %0, %c0 : memref<101xf32>
10451045
%cf7 = constant 7.0 : f32
10461046

1047-
affine.for %i0 = 0 to 100 {
1047+
affine.for %i0 = 0 to 101 {
10481048
affine.if #set1(%i0)[%N] {
10491049
%1 = affine.load %0[%i0] : memref<101xf32>
10501050
// expected-remark@above {{dependence from 0 to 0 at depth 1 = false}}

0 commit comments

Comments
 (0)