More simplification for affine binary op expr's.
- simplify operations with identity elements (multiply by 1, add with 0).
- simplify successive add/mul: fold constants, propagate constants to the
right.
- simplify floordiv and ceildiv when divisors are constants, and the LHS is a
multiply expression with RHS constant.
- fix an affine expression printing bug on paren emission.
- while on this, fix affine-map test cases file (memref's using layout maps
that were duplicates of existing ones should be emitted pointing to the
unique'd one).
PiperOrigin-RevId: 207046738
diff --git a/lib/IR/AsmPrinter.cpp b/lib/IR/AsmPrinter.cpp
index f881872..3db030b 100644
--- a/lib/IR/AsmPrinter.cpp
+++ b/lib/IR/AsmPrinter.cpp
@@ -454,9 +454,9 @@
if (rrhs->getValue() < -1) {
printAffineExprInternal(binOp->getLHS(), BindingStrength::Weak);
- os << " - (";
+ os << " - ";
printAffineExprInternal(rhs->getLHS(), BindingStrength::Strong);
- os << " * " << -rrhs->getValue() << ')';
+ os << " * " << -rrhs->getValue();
if (enclosingTightness == BindingStrength::Strong)
os << ')';
return;