Skip to content

Commit 67adece

Browse files
committed
"drop constants case"
1 parent 0fd934f commit 67adece

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

mlir/lib/IR/AffineExpr.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -784,11 +784,12 @@ static AffineExpr simplifyAdd(AffineExpr lhs, AffineExpr rhs) {
784784
return nullptr;
785785
}
786786

787+
/// Get the canonical order of two commutative exprs arguments.
787788
static std::pair<AffineExpr, AffineExpr>
788789
orderCommutativeArgs(AffineExpr expr1, AffineExpr expr2) {
789790
auto sym1 = dyn_cast<AffineSymbolExpr>(expr1);
790791
auto sym2 = dyn_cast<AffineSymbolExpr>(expr2);
791-
// Try to order by symbol/dim position first
792+
// Try to order by symbol/dim position first.
792793
if (sym1 && sym2)
793794
return sym1.getPosition() < sym2.getPosition() ? std::pair{expr1, expr2}
794795
: std::pair{expr2, expr1};
@@ -799,18 +800,14 @@ orderCommutativeArgs(AffineExpr expr1, AffineExpr expr2) {
799800
return dim1.getPosition() < dim2.getPosition() ? std::pair{expr1, expr2}
800801
: std::pair{expr2, expr1};
801802

802-
// Put dims before symbols
803+
// Put dims before symbols.
803804
if (dim1 && sym2)
804805
return {dim1, sym2};
805806

806807
if (sym1 && dim2)
807808
return {dim2, sym1};
808809

809-
// Move constants to the right
810-
if (isa<AffineConstantExpr>(expr1) && !isa<AffineConstantExpr>(expr2))
811-
return {expr2, expr1};
812-
813-
// Otherwise, keep original order
810+
// Otherwise, keep original order.
814811
return {expr1, expr2};
815812
}
816813

0 commit comments

Comments
 (0)