[Mlir-commits] [mlir] Fix bug in `visitDivExpr`, `visitModExpr` and `visitMulExpr` (PR #145290)
Uday Bondhugula
llvmlistbot at llvm.org
Tue Jul 1 09:35:01 PDT 2025
================
@@ -1274,6 +1273,27 @@ SimpleAffineExprFlattener::SimpleAffineExprFlattener(unsigned numDims,
operandExprStack.reserve(8);
}
+LogicalResult SimpleAffineExprFlattener::addExprToFlattenedList(
+ AffineExpr expr, ArrayRef<int64_t> lhs, ArrayRef<int64_t> rhs,
+ SmallVectorImpl<int64_t> &result) {
+ if (auto constExpr = dyn_cast<AffineConstantExpr>(expr)) {
+ std::fill(result.begin(), result.end(), 0);
+ result[getConstantIndex()] = constExpr.getValue();
+ return success();
+ }
+ if (auto dimExpr = dyn_cast<AffineDimExpr>(expr)) {
+ std::fill(result.begin(), result.end(), 0);
+ result[getDimStartIndex() + dimExpr.getPosition()] = 1;
+ return success();
+ }
+ if (auto symExpr = dyn_cast<AffineSymbolExpr>(expr)) {
+ std::fill(result.begin(), result.end(), 0);
+ result[getSymbolStartIndex() + symExpr.getPosition()] = 1;
+ return success();
+ }
+ return addLocalVariableSemiAffine(lhs, rhs, expr, result, result.size());
----------------
bondhugula wrote:
How do we know that `expr` is semi-affine at this stage? It can just be a purely affine binary expression. This method is confusing without any further comments. At this point, all you know is that `expr` is an affine binary expression and you might as well `cast` it to that and send it to make the signature of addLocal... less confusing.
https://github.com/llvm/llvm-project/pull/145290
More information about the Mlir-commits
mailing list