From eb47d5ee66e2e3dc4d9f2fc7768c41f6b037f3db Mon Sep 17 00:00:00 2001 From: Uday Bondhugula Date: Thu, 7 Nov 2019 10:26:51 -0800 Subject: Fix asm printer for affine expr - fixes tensorflow/mlir#201 Signed-off-by: Uday Bondhugula Closes tensorflow/mlir#204 COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/204 from bondhugula:printfix 3f8a5b65391f45598258b2735fecaa409fbde848 PiperOrigin-RevId: 279115720 --- mlir/lib/IR/AsmPrinter.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'mlir/lib/IR/AsmPrinter.cpp') diff --git a/mlir/lib/IR/AsmPrinter.cpp b/mlir/lib/IR/AsmPrinter.cpp index 0d0c40cdd1e..43452b2712d 100644 --- a/mlir/lib/IR/AsmPrinter.cpp +++ b/mlir/lib/IR/AsmPrinter.cpp @@ -1182,9 +1182,12 @@ void ModulePrinter::printAffineExprInternal( // Pretty print multiplication with -1. auto rhsConst = rhsExpr.dyn_cast(); - if (rhsConst && rhsConst.getValue() == -1) { + if (rhsConst && binOp.getKind() == AffineExprKind::Mul && + rhsConst.getValue() == -1) { os << "-"; printAffineExprInternal(lhsExpr, BindingStrength::Strong, printValueName); + if (enclosingTightness == BindingStrength::Strong) + os << ')'; return; } -- cgit v1.2.3