[Mlir-commits] [mlir] [MLIR] Add trivial simplifications for affine mod, div, ceil (PR #182234)
Matthias Springer
llvmlistbot at llvm.org
Thu Feb 19 00:21:34 PST 2026
================
@@ -912,13 +912,17 @@ AffineExpr AffineExpr::operator-(AffineExpr other) const {
}
static AffineExpr simplifyFloorDiv(AffineExpr lhs, AffineExpr rhs) {
- auto lhsConst = dyn_cast<AffineConstantExpr>(lhs);
auto rhsConst = dyn_cast<AffineConstantExpr>(rhs);
+ // For the defined cases, simplify x floordiv x is 1.
+ if (lhs == rhs && (!rhsConst || rhsConst.getValue() >= 1))
----------------
matthias-springer wrote:
Also why is this check needed: `rhsConst.getValue() >= 1`? Dividing two equal negative numbers is also `1`.
https://github.com/llvm/llvm-project/pull/182234
More information about the Mlir-commits
mailing list