-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[mlir] Don't assert when simplifying certain AffineExpr
s
#78855
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-mlir @llvm/pr-subscribers-mlir-core Author: Felix Schneider (ubfx) ChangesCurrently, Fix #75770 Full diff: https://github.com/llvm/llvm-project/pull/78855.diff 1 Files Affected:
diff --git a/mlir/lib/IR/AffineExpr.cpp b/mlir/lib/IR/AffineExpr.cpp
index a90b264a8edd26..77c8fcc96d0ea0 100644
--- a/mlir/lib/IR/AffineExpr.cpp
+++ b/mlir/lib/IR/AffineExpr.cpp
@@ -774,7 +774,8 @@ static AffineExpr simplifyMul(AffineExpr lhs, AffineExpr rhs) {
return getAffineConstantExpr(lhsConst.getValue() * rhsConst.getValue(),
lhs.getContext());
- assert(lhs.isSymbolicOrConstant() || rhs.isSymbolicOrConstant());
+ if (!lhs.isSymbolicOrConstant() && !rhs.isSymbolicOrConstant())
+ return nullptr;
// Canonicalize the mul expression so that the constant/symbolic term is the
// RHS. If both the lhs and rhs are symbolic, swap them if the lhs is a
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way to test this? Perhaps in a unit test?
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.
ba7b34b
to
b452fa8
Compare
b452fa8
to
1c7fcab
Compare
@ftynse Like this? Or were you thinking a more thorough test with walking the resulting |
Good enough. I usually add the minimized test case that triggered the assertion in the first place, this lets us catch an eventual regression. |
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. Fix llvm#75770
Currently,
simplifyMul()
asserts that eitherlhs
orrhs
is symbolic or constant. This method is called by the overloaded*
operator forAffineExpr
s which leads to a crash when building a multiplication expression where neither operand is symbolic or constant.This patch returns a
nullptr
fromsimplifyMul()
to signal that the expression could not be simplified instead.Fix #75770