Skip to content

Commit 12894bb

Browse files
committed
[mlir] Don't assert when simplifying certain AffineExprs
Currently, `simplifyMul()` asserts that either `lhs` or `rhs` is symbolic or constant. This method is called by the overloaded `*` operator for `AffineExpr`s which leads to a crash when building a multiplication expression where neither operand is symbolic or constant. This patch returns a `nullptr` from `simplifyMul()` to signal that the expression could not be simplified instead.
1 parent 27d7bb8 commit 12894bb

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

mlir/lib/IR/AffineExpr.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -774,7 +774,8 @@ static AffineExpr simplifyMul(AffineExpr lhs, AffineExpr rhs) {
774774
return getAffineConstantExpr(lhsConst.getValue() * rhsConst.getValue(),
775775
lhs.getContext());
776776

777-
assert(lhs.isSymbolicOrConstant() || rhs.isSymbolicOrConstant());
777+
if (!lhs.isSymbolicOrConstant() && !rhs.isSymbolicOrConstant())
778+
return nullptr;
778779

779780
// Canonicalize the mul expression so that the constant/symbolic term is the
780781
// RHS. If both the lhs and rhs are symbolic, swap them if the lhs is a

0 commit comments

Comments
 (0)